Hyperlinkv0.8.0-beta.28

Stream

Stream.fromPubSubTakeconsteffect/Stream.ts:1362
<A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): Stream<A, E>

Creates a stream from a PubSub of Take values.

Details

Take values include end and failure signals.

Example (Creating a stream from PubSub takes)

import { Console, Effect, Exit, PubSub, Stream, Take } from "effect"

const program = Effect.gen(function*() {
  const pubsub = yield* PubSub.unbounded<Take.Take<number, string>>({
    replay: 3
  })

  yield* PubSub.publish(pubsub, [1])
  yield* PubSub.publish(pubsub, [2])
  yield* PubSub.publish(pubsub, Exit.succeed<void>(undefined))

  const values = yield* Stream.fromPubSubTake(pubsub).pipe(Stream.runCollect)
  yield* Console.log(values)
})

Effect.runPromise(program)
// Output: [ 1, 2 ]
constructors
Source effect/Stream.ts:13622 lines
export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): Stream<A, E> =>
  fromChannel(Channel.fromPubSubTake(pubsub))
Referenced by 1 symbols