Hyperlinkv0.8.0-beta.28

Stream

Stream.suspendconsteffect/Stream.ts:902
<A, E, R>(stream: LazyArg<Stream<A, E, R>>): Stream<A, E, R>

Creates a lazily constructed stream.

Details

The stream factory is evaluated each time the stream is run.

Example (Creating a lazily constructed stream)

import { Console, Effect, Stream } from "effect"

const program = Effect.gen(function*() {
  const values = yield* Stream.suspend(() => Stream.make(1, 2, 3)).pipe(Stream.runCollect)
  yield* Console.log(values)
})

Effect.runPromise(program)
// Output: [ 1, 2, 3 ]
constructors
Source effect/Stream.ts:9022 lines
export const suspend = <A, E, R>(stream: LazyArg<Stream<A, E, R>>): Stream<A, E, R> =>
  fromChannel(Channel.suspend(() => stream().channel))
Referenced by 7 symbols