@epikodelabs/streamix / ForkOption
Interface: ForkOption<T, R>
Defined in: projects/libraries/streamix/src/lib/operators/fork.ts:14
Represents a conditional branch for the fork operator.
Each ForkOption defines:
- A predicate function
onto test source values. - A handler function
handlerthat produces a stream (or value/array/promise) when the predicate matches.
Type Parameters
T
T = any
The type of values in the source stream.
R
R = any
The type of values emitted by the handler and output stream.
Properties
on()
on: (
value,index) =>MaybePromise<boolean>
Defined in: projects/libraries/streamix/src/lib/operators/fork.ts:22
Predicate function to determine if this option should handle a value.
Parameters
value
T
The value from the source stream.
index
number
The zero-based index of the value in the source stream.
Returns
MaybePromise<boolean>
A boolean or a Promise<boolean> indicating whether this option matches.
handler()
handler: (
value) =>Stream<R> |MaybePromise<R> |R[]
Defined in: projects/libraries/streamix/src/lib/operators/fork.ts:35
Handler function called for values that match the predicate.
Can return:
Parameters
value
T
The source value that matched the predicate.
Returns
Stream<R> | MaybePromise<R> | R[]
A stream, value, promise, or array to be flattened and emitted.