Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

observable_iterator_on_tick

crates.io ci codecov license

Emits iterator items one per scheduler tick.

See Also

Example

Run the example with:

cargo run -p rx_core --example observable_iterator_on_tick_example
let mut executor = MockExecutor::default();
let scheduler = executor.get_scheduler_handle();

let iterator_observable = IteratorOnTickObservable::new(
    0..=7,
    OnTickObservableOptions {
        start_on_subscribe: true,
        emit_at_every_nth_tick: 2,
    },
    scheduler,
);
let _subscription = iterator_observable
    .finalize(|| println!("fin"))
    .subscribe(PrintObserver::new("iterator_on_tick"));
println!("subscribed!");

executor.tick(Duration::from_millis(500));
executor.tick(Duration::from_millis(16));
executor.tick(Duration::from_millis(9001));
executor.tick(Duration::from_millis(0));
executor.tick(Duration::from_millis(10));

Output:

iterator_on_tick - next: 0
subscribed!
iterator_on_tick - next: 1
iterator_on_tick - next: 2
fin
iterator_on_tick - unsubscribed