Function timeoutValue

  • Emits a value if source does not emit a value after interval has elapsed. This can be useful to reset a reactive to some 'zero' state if nothing is going on.

    If source emits faster than the interval, it won't get triggered.

    Default for 'timeout': 1000s.

    // Emit 'hello' if 'source' doesn't emit a value after 1 minute
    const r = Rx.timeoutValue(source, { value: 'hello', interval: { mins: 1 } });

    Can also emit results from a function or generator

    // Emits a random number if 'source' doesn't emit a value after 500ms
    const r = Rx.timeoutValue(source, { fn: Math.random, interval: 500 });

    If immediate option is true (default), the timer starts from stream initialisation. Otherwise it won't start until it observes the first value from source.

    Type Parameters

    • TSource
    • TTriggerValue

    Returns Reactive<TSource | TTriggerValue>