Hyperlinkv0.8.0-beta.28

Stream

Stream.fromEffectRepeatconsteffect/Stream.ts:494
<A, E, R>(effect: Effect.Effect<A, E, R>): Stream<
  A,
  Pull.ExcludeDone<E>,
  R
>

Creates a stream from an effect producing a value of type A which repeats forever.

Example (Repeating an effect forever)

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

const program = Effect.gen(function*() {
  const stream = Stream.fromEffectRepeat(Random.nextInt).pipe(
    Stream.take(5)
  )
  const values = yield* Stream.runCollect(stream)
  yield* Console.log(values)
})

Effect.runPromise(program)
// Output: [ 3891571149, 4239494205, 2352981603, 2339111046, 1488052210 ]
constructors
Source effect/Stream.ts:4942 lines
export const fromEffectRepeat = <A, E, R>(effect: Effect.Effect<A, E, R>): Stream<A, Pull.ExcludeDone<E>, R> =>
  fromPull(Effect.succeed(Effect.map(effect, Arr.of)))
Referenced by 2 symbols