{"id":19502373,"url":"https://github.com/zio-archive/interop-monix","last_synced_at":"2025-04-26T00:31:52.013Z","repository":{"id":34964831,"uuid":"191025633","full_name":"zio-archive/interop-monix","owner":"zio-archive","description":null,"archived":true,"fork":false,"pushed_at":"2024-08-20T01:41:27.000Z","size":236,"stargazers_count":8,"open_issues_count":31,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-22T15:01:16.741Z","etag":null,"topics":["interoperability","monix","scala","zio"],"latest_commit_sha":null,"homepage":"https://zio.dev/interop-monix","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zio-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-09T15:50:13.000Z","updated_at":"2025-01-20T13:00:37.000Z","dependencies_parsed_at":"2023-02-16T02:46:23.849Z","dependency_job_id":"cb828351-aec1-4d4e-98dc-038b6820bcc8","html_url":"https://github.com/zio-archive/interop-monix","commit_stats":{"total_commits":171,"total_committers":10,"mean_commits":17.1,"dds":"0.32163742690058483","last_synced_commit":"49bd2fa51a9c275bbbabefbf970dd74152eec707"},"previous_names":["zio-archive/interop-monix"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio-archive%2Finterop-monix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio-archive%2Finterop-monix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio-archive%2Finterop-monix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio-archive%2Finterop-monix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zio-archive","download_url":"https://codeload.github.com/zio-archive/interop-monix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250917284,"owners_count":21507561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interoperability","monix","scala","zio"],"created_at":"2024-11-10T22:16:14.839Z","updated_at":"2025-04-26T00:31:51.740Z","avatar_url":"https://github.com/zio-archive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[//]: # (This file was autogenerated using `zio-sbt-website` plugin via `sbt generateReadme` command.)\n[//]: # (So please do not edit it manually. Instead, change \"docs/index.md\" file or sbt setting keys)\n[//]: # (e.g. \"readmeDocumentation\" and \"readmeSupport\".)\n\n# ZIO Interop Monix\n\nThis library provides interoperability between **Monix 3.4** and **ZIO 1 and ZIO 2**. Both JVM and Scala.js are supported.\n\n[![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)](https://github.com/zio/zio/wiki/Project-Stages) ![CI Badge](https://github.com/zio/interop-monix/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-interop-monix_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-interop-monix_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-interop-monix_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-interop-monix_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/interop-monix-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/interop-monix-docs_2.13) [![ZIO Interop Monix](https://img.shields.io/github/stars/zio/interop-monix?style=social)](https://github.com/zio/interop-monix)\n\n## Installation\n\nIn order to use this library, we need to add the following line in our `build.sbt` file:\n\n```scala\nlibraryDependencies += \"dev.zio\" %% \"zio-interop-monix\" % \"3.4.2.1.1\"\n```\n\n## Tasks\n\nMonix tasks can be converted to ZIO tasks:\n\n```scala\nimport zio._\nimport zio.interop.monix._\nimport monix.eval\n\nval monixTask: eval.Task[String] = ???\n\nval zioTask: Task[String] = ZIO.fromMonixTask(monixTask)\n```\n\nThe conversion is lazy: the Monix task will only be executed if the returned ZIO task is executed.\n\nZIO tasks can be converted to Monix tasks:\n\n```scala\nimport zio._\nimport zio.interop.monix._\nimport monix.eval\nimport monix.execution.Scheduler.Implicits.global\n\nval zioTask: Task[String] = ???\n\nval createMonixTask: UIO[eval.Task[String]] = zioTask.toMonixTask()\n\n// illustrative, you wouldn't usually do things this way\nval monixTask: eval.Task[String] = Runtime.default.unsafeRun(createMonixTask)\nval stringResult = monixTask.runSyncUnsafe\n```\n\nThe conversion is lazy: the ZIO effect so converted will only be executed if the returned Monix task is executed.\n\nSometimes you need to provide a Monix task in a context where using a ZIO effect is difficult. For example, when an API requires you to provide a function that returns a Monix task. In these situations, the `toMonixTaskUsingRuntime` method can be used:\n\n```scala\nimport zio._\nimport zio.interop.monix._\nimport monix.eval\n\ndef monixBasedApi(f: String =\u003e eval.Task[Unit]): eval.Task[Unit] = ???\n\ndef zioBasedProcessor(s: String): Task[Unit] = ???\n\nval zioEffects = for {\n    zioRuntime \u003c- ZIO.runtime[Any]\n    _ \u003c- ZIO.fromMonixTask {\n        monixBasedApi(s =\u003e\n            zioBasedProcessor(s).toMonixTaskUsingRuntime(zioRuntime)\n        )\n    }\n} yield ()\n```\n\nCancellation/Interruption is propagated between the effect systems. Interrupting a ZIO task based on a Monix task will cancel the underlying Monix task and vice-versa. Be aware that ZIO interruption does not return until cancellation effects have completed, whereas Monix cancellation returns as soon as the signal is sent, without waiting for the cancellation effects to complete.\n\n## Monix Scheduler\n\nSometimes it is useful to have a Monix `Scheduler` available for interop purposes. The `Runtime#monixScheduler` method will create a scheduler that shares its execution context with the ZIO runtime:\n\n```scala\nimport zio._\nimport zio.interop.monix._\nimport monix.execution.Scheduler\n\nZIO.runtime[Any].flatMap { runtime =\u003e\n    implicit val monixScheduler: Scheduler = runtime.monixScheduler()\n\n    // do Monixy things\n}\n```\n\n## Documentation\n\nLearn more on the [ZIO Interop Monix homepage](https://zio.dev/interop-monix/)!\n\n## Contributing\n\nFor the general guidelines, see ZIO [contributor's guide](https://zio.dev/about/contributing).\n\n## Code of Conduct\n\nSee the [Code of Conduct](https://zio.dev/about/code-of-conduct)\n\n## Support\n\nCome chat with us on [![Badge-Discord]][Link-Discord].\n\n[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord \"chat on discord\"\n[Link-Discord]: https://discord.gg/2ccFBr4 \"Discord\"\n\n## License\n\n[License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio-archive%2Finterop-monix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzio-archive%2Finterop-monix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio-archive%2Finterop-monix/lists"}