package interop
Package Members
- package reactivestreams
Implementation of the reactivestreams protocol for fs2
Implementation of the reactivestreams protocol for fs2
- Deprecated
The next major version of fs2 will drop these converters. Rather, users will be encouraged to use the new fs2.interop.flow package, which provides support for the
java.util.concurrent.Flow
types; that superseded thereactive-streams
library. In case you need to interop with a library that only providesreactive-streams
types, you may useorg.reactivestreams.FlowAdapters
scala> import fs2._ scala> import fs2.interop.reactivestreams._ scala> import cats.effect.{IO, Resource}, cats.effect.unsafe.implicits.global scala> scala> val upstream: Stream[IO, Int] = Stream(1, 2, 3).covary[IO] scala> val publisher: Resource[IO, StreamUnicastPublisher[IO, Int]] = upstream.toUnicastPublisher scala> val downstream: Stream[IO, Int] = Stream.resource(publisher).flatMap(_.toStreamBuffered[IO](bufferSize = 16)) scala> scala> downstream.compile.toVector.unsafeRunSync() res0: Vector[Int] = Vector(1, 2, 3)
- See also
Example: