Function combineLatestToArray

  • Monitors input reactive values, storing values as they happen to an array. Whenever a new value is emitted, the whole array is sent out, containing current values from each source, or undefined if not yet emitted.

    See combineLatestToObject to combine streams by name into an object, rather than array.

    const sources = [
    Rx.fromFunction(Math.random, { loop: true, interval: 100 }),
    Rx.fromFunction(Math.random, { loop: true, interval: 200 })
    ];
    const r = Rx.combineLatestToArray(sources);
    r.onValue(value => {
    // Value will be an array of last value from each source:
    // [number,number]
    });

    The tempo of this stream will be set by the fastest source stream. See syncToArray to have pace determined by slowest source, and only send when each source has produce a new value compared to last time.

    Set onSourceDone to choose behaviour if a source stops. By default it is 'break', meaning the whole merged stream stops.

    Note: unlike RxJS's combineLatest, does not wait for each source to emit once before emitting first value.

    Type Parameters

    Parameters

    Returns Reactive<RxValueTypes<T>>