promiseRace
The input streams or subjections compete, returning a new stream that fork
s from the stream that pushes data first.
Type
typescripttype promiseRace: (...args: (Stream | Subjection)[]) => Stream;
Details
- After the input stream unsubscribes or finishes, the new stream will also unsubscribe or finish.
Example
typescriptimport { $, promiseRace } from "fluth"; const stream1$ = $(1); const stream2$ = $("hello"); const stream3$ = $(false); const promiseRace$ = promiseRace(stream1$, stream2$, stream3$); promiseRace$.then((value) => console.log(value)); stream2$.next("world"); // prints: "hello" stream3$.next(true); stream1$.next(3); stream2$.next("code"); // prints: "code"