{"id":15289169,"url":"https://github.com/zio-archive/interop-reactive-streams","last_synced_at":"2025-08-20T20:32:35.562Z","repository":{"id":34964828,"uuid":"191025995","full_name":"zio/interop-reactive-streams","owner":"zio","description":"Interoperability Layer Between ZIO and Reactive Streams","archived":false,"fork":false,"pushed_at":"2024-05-30T06:40:55.000Z","size":349,"stargazers_count":47,"open_issues_count":18,"forks_count":26,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-15T22:43:52.722Z","etag":null,"topics":["reactive-streams","scala","zio"],"latest_commit_sha":null,"homepage":"https://zio.dev/zio-interop-reactivestreams","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.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:53:25.000Z","updated_at":"2023-12-14T08:23:01.000Z","dependencies_parsed_at":"2023-02-13T03:01:23.286Z","dependency_job_id":"20378531-3a5f-4647-a201-0884c416d51f","html_url":"https://github.com/zio/interop-reactive-streams","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Finterop-reactive-streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Finterop-reactive-streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Finterop-reactive-streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zio%2Finterop-reactive-streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zio","download_url":"https://codeload.github.com/zio/interop-reactive-streams/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230454429,"owners_count":18228392,"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":["reactive-streams","scala","zio"],"created_at":"2024-09-30T15:59:28.798Z","updated_at":"2025-08-20T20:32:30.226Z","avatar_url":"https://github.com/zio.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 Reactive Streams\n\nThis library provides an interoperability layer between ZIO and reactive streams.\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-reactive-streams/workflows/CI/badge.svg) [![Sonatype Releases](https://img.shields.io/nexus/r/https/oss.sonatype.org/dev.zio/zio-interop-reactivestreams_2.13.svg?label=Sonatype%20Release)](https://oss.sonatype.org/content/repositories/releases/dev/zio/zio-interop-reactivestreams_2.13/) [![Sonatype Snapshots](https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.zio/zio-interop-reactivestreams_2.13.svg?label=Sonatype%20Snapshot)](https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio-interop-reactivestreams_2.13/) [![javadoc](https://javadoc.io/badge2/dev.zio/zio-interop-reactivestreams-docs_2.13/javadoc.svg)](https://javadoc.io/doc/dev.zio/zio-interop-reactivestreams-docs_2.13) [![ZIO Interop Reactive Streams](https://img.shields.io/github/stars/zio/interop-reactive-streams?style=social)](https://github.com/zio/interop-reactive-streams)\n\n## Introduction\n\n**ZIO** integrates with [Reactive Streams](http://reactive-streams.org) by providing conversions from `zio.stream.Stream` to `org.reactivestreams.Publisher` and from `zio.stream.Sink` to `org.reactivestreams.Subscriber` and vice versa. Simply import `import zio.interop.reactivestreams._` to make the conversions available.\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-reactivestreams\" % \"2.0.2\"\n```\n\n## Examples\n\nFirst, let's get a few imports out of the way.\n\n```scala\nimport org.reactivestreams.example.unicast._\nimport zio._\nimport zio.interop.reactivestreams._\nimport zio.stream._\n```\n\nWe use the following `Publisher` and `Subscriber` for the examples:\n\n```scala\nval publisher = new RangePublisher(3, 10)\nval subscriber = new SyncSubscriber[Int] {\n  override protected def whenNext(v: Int): Boolean = {\n    print(s\"$v, \")\n    true\n  }\n}\n```\n\n### Publisher to Stream\n\nA `Publisher` used as a `Stream` buffers up to `qSize` elements. If possible, `qSize` should be\na power of two for best performance. The default is 16.\n\n```scala\nval streamFromPublisher = publisher.toZIOStream(qSize = 16)\nstreamFromPublisher.run(Sink.collectAll[Integer])\n```\n\n### Subscriber to Sink\n\nWhen running a `Stream` to a `Subscriber`, a side channel is needed for signalling failures.\nFor this reason `toZIOSink` returns a tuple of a callback and a `Sink`. The callback must be used to signal `Stream` failure. The type parameter on `toZIOSink` is the error type of *the Stream*.\n\n```scala\nval asSink = subscriber.toZIOSink[Throwable]\nval failingStream = ZStream.range(3, 13) ++ ZStream.fail(new RuntimeException(\"boom!\"))\nZIO.scoped {\n  asSink.flatMap { case (signalError, sink) =\u003e // FIXME\n    failingStream.run(sink).catchAll(signalError)\n  }\n}\n```\n\n### Stream to Publisher\n\n```scala\nval stream = Stream.range(3, 13)\nstream.toPublisher.flatMap { publisher =\u003e\n  UIO(publisher.subscribe(subscriber))\n}\n```\n\n### Sink to Subscriber\n\n`toSubscriber` returns a `Subscriber` and an `IO` which completes with the result of running the `Sink` or the error if the `Publisher` fails.\nA `Sink` used as a `Subscriber` buffers up to `qSize` elements. If possible, `qSize` should be a power of two for best performance. The default is 16.\n\n```scala\nval sink = Sink.collectAll[Integer]\nZIO.scoped {\n  sink.toSubscriber(qSize = 16).flatMap { case (subscriber, result) =\u003e \n    UIO(publisher.subscribe(subscriber)) *\u003e result\n  }\n}\n```\n\n## Documentation\n\nLearn more on the [ZIO Interop Reactive Streams homepage](https://zio.dev/zio-interop-reactivestreams)!\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-reactive-streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzio-archive%2Finterop-reactive-streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzio-archive%2Finterop-reactive-streams/lists"}