wait Method
Waits for the first values from multiple emitters, states, or observables, applies a reducer function to these values, emits the resulting value to all subscribers of this emitter, and completes the stream
@param ...inputs: [...EmitterOrObservableTuple<I>, SpreadFn<I, T>]
A spread of emitters, states, or observables, followed by a reducer function. The reducer function
takes the first values from each source as arguments and returns the value to be emitted
@returns this
The instance of the emitter, allowing for method chaining
API
wait<I extends any[]>(...inputs: [...EmitterOrObservableTuple<I>, SpreadFn<I, T>]): this;
Example
import {of} from 'rxjs';
import {emitter, state} from '@bitfiber/rx';
type Result = {id: number; data: string; count: number};
const id = emitter<number>();
const data = state<string>(1);
const count$ = of(1);
const result = emitter<number>(e => e
// Waits the first values from all reactive sources, emits a reducer function value to
// its subscribers, and completes the stream
.wait(id, data, count$, (id, data, count) => count));