You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation still mentions only the deprecated reactive streams
interop features. Now interop with Java Flow can be done directly on the
`Stream` class and companion object. This should be reflected in the
documentation.
See [`Queue`](https://github.com/typelevel/cats-effect/blob/series/3.x/std/shared/src/main/scala/cats/effect/std/Queue.scala)
783
783
for more useful methods. Most concurrent queues in cats effect support tracking their size, which is handy for implementing size-based throttling of the producer.
784
784
785
-
###Reactive streams
785
+
###JavaFlow and reactive streams
786
786
787
-
The [reactive streams initiative](http://www.reactive-streams.org/) is complicated, mutable and unsafe - it is not something that is desired for use over fs2.
787
+
The [reactive streams initiative](http://www.reactive-streams.org/) and its successor `java.util.concurrent.Flow` are complicated, mutable and unsafe - it is not something that is desired for use over fs2.
788
788
But there are times when we need use fs2 in conjunction with a different streaming library, and this is where reactive streams shines.
789
789
790
-
Any reactive streams system can interoperate with any other reactive streams system by exposing an `org.reactivestreams.Publisher` or an `org.reactivestreams.Subscriber`.
790
+
Any reactive streams system can interoperate with any other reactive streams system by exposing a `Publisher` or a `Subscriber`.
791
791
792
-
The `reactive-streams` library provides instances of reactive streams compliant publishers and subscribers to ease interoperability with other streaming libraries.
792
+
FS2 provides instances of reactive streams compliant publishers and subscribers to ease interoperability with other streaming libraries.
793
793
794
-
####Usage
794
+
####UsagewithJavaFlow
795
795
796
796
You may require the following imports:
797
797
798
798
```scala mdoc:reset
799
799
importfs2._
800
-
importfs2.interop.reactivestreams._
801
800
importcats.effect.{IO, Resource}
801
+
importjava.util.concurrent.Flow.Publisher
802
+
```
803
+
804
+
To convert a `Stream` into a downstream `java.util.concurrent.Flow.Publisher`:
805
+
806
+
```scala mdoc
807
+
valstream=Stream(1, 2, 3).covary[IO]
808
+
stream.toPublisherResource
809
+
```
810
+
811
+
To convert an upstream `java.util.concurrent.Publisher` into a `Stream`:
If your are integrating a library that is still using `org.reactivestreams.Publisher`, you can use `org.reactivestreams.FlowAdapters` to convert to JavaFlow.
0 commit comments