Function singleFromArray

  • For a stream that emits arrays of values, this op will select a single value.

    Can select based on:

    • predicate: a function that returns true for a value
    • at: selection based on array index (can be combined with random ordering to select a random value)
    // If source is Reactive<Array<number>>, picks the first even number
    singleFromArray(source, {
    predicate: v => v % 2 === 0
    });

    // Selects a random value from source
    singleFromArray(source, {
    order: `random`,
    at: 0
    });

    If neither predicate or at options are given, exception is thrown.

    Type Parameters

    • V

    Parameters

    Returns Reactive<V>