Function count

  • Produces an incrementing value. By default starts at 0 and counts forever, incrementing every second.

    const r = Rx.count();
    r.onValue(c => {
    // 0, 1, 2, 3 ... every second
    });

    The limit is exclusive

    const r = Rx.count({limit:5});
    // Yields 0,1,2,3,4

    If limit is less than start, it will count down instead.

    const r = Rx.count({start:5, limit: 0});
    // Yie:ds 5,4,3,2,1
    // Count 10, 12, 14 ... every 500ms
    const r = Rx.count({ start: 10, amount: 2, interval: 500 });

    In addition to setting limit (which is exclusive), you can stop with an abort signal

    const ac = new AbortController();
    const r = Rx.count({signal:ac.signal});
    ...
    ac.abort(`stop`);

    Parameters

    Returns ReactiveStream<number>