effect-io-ai

Package: effect
Module: Sink

Sink.flatMap

Runs this sink until it yields a result, then uses that result to create another sink from the provided function which will continue to run until it yields a result.

When to use

Use to compose sinks when the next sink depends on the result produced by the previous sink.

Details

Leftovers from the first sink are fed to the sink returned by f before more upstream input is pulled.

See

Signature

declare const flatMap: { <A, A1, L, In1 extends L, L1, E1, R1>(f: (a: A) => Sink<A1, In1, L1, E1, R1>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A1, In & In1, L1 | L, E1 | E, R1 | R>; <A, In, L, E, R, A1, In1 extends L, L1, E1, R1>(self: Sink<A, In, L, E, R>, f: (a: A) => Sink<A1, In1, L1, E1, R1>): Sink<A1, In & In1, L | L1, E | E1, R | R1>; }

Source

Since v2.0.0