Skip to content

Commit

Permalink
Document fromPublisher + how to interop with FS2
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Jan 20, 2024
1 parent e1c53d5 commit e432edf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,21 @@ If you have an `Observable[Future[A]]`, you can flatten it into `Observable[A]`

A failed future results in an error (see [Error Handling](#error-handling)).

#### Creating Observables from other Streaming APIs

`EventStream.fromPublisher[A]` creates a stream that subscribes to a Reactive Streams [Publisher](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/Flow.Publisher.html) and emits the values that it produces.

`Publisher` is a common interface that is useful for interoperating between streaming APIs. For example, you can transform an [FS2](https://fs2.io/) `Stream[IO, A]` into an `EventStream[A]`.

```scala
import cats.effect.unsafe.implicits._ // implicit IORuntime
EventStream.fromPublisher(fs2Stream.unsafeToPublisher())
```

#### `EventStream.fromJsPromise` and `Signal.fromJsPromise`

Behave the same as `fromFuture` above, but accept `js.Promise` instead. Useful for integration with JS libraries and APIs.


#### `EventStream.fromSeq`

```scala
Expand Down

0 comments on commit e432edf

Please sign in to comment.