arrow-fx-coroutines / arrow.fx.coroutines.stream / Stream / defer

defer

fun <O> defer(s: () -> Stream<O>): Stream<O>

Returns a stream that evaluates s each time the stream is used, allowing use of a mutable value in stream computations.

Note: it’s generally easier to reason about such computations using effectful values. That is, allocate the mutable value in an effect and then use Stream.effect(fa).flatMap { a -> ??? }.

Do you like Arrow?

Arrow Org
<