Package: effect
Module: Stream
Converts a stream to a PubSub of Take values for concurrent consumption.
Details
Take values include the stream’s end and failure signals.
Example (Converting to a PubSub of takes)
import { Console, Effect, PubSub, Stream } from "effect"
const program = Effect.gen(function* () {
const pubsub = yield* Stream.fromArray([1, 2, 3]).pipe(
Stream.toPubSubTake({ capacity: 8 })
)
const subscription = yield* PubSub.subscribe(pubsub)
const take = yield* PubSub.take(subscription)
if (Array.isArray(take)) {
yield* Console.log(take)
}
})
Signature
declare const toPubSubTake: { (options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; }): <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<PubSub.PubSub<Take.Take<A, E>>, never, R | Scope.Scope>; <A, E, R>(self: Stream<A, E, R>, options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; }): Effect.Effect<PubSub.PubSub<Take.Take<A, E>>, never, R | Scope.Scope>; }
Since v4.0.0