Package: effect
Module: Stream
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 ]
Signature
declare const fromEffectRepeat: <A, E, R>(effect: Effect.Effect<A, E, R>) => Stream<A, Pull.ExcludeDone<E>, R>
Since v4.0.0