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

operator_observe_on

crates.io ci codecov license

The observe_on operator re-emits upstream next signals on the provided scheduler.

Upstream completion and cancellation happen immediately when there are no pending scheduled values, otherwise they are deferred until scheduled work drains.

Upstream errors are forwarded immediately; any pending scheduled values are skipped because downstream closes.

See Also

Example

cargo run -p rx_core --example operator_observe_on_example
use std::time::Duration;

use rx_core::prelude::*;
use rx_core_testing::MockExecutor;

fn main() {
    let mut executor = MockExecutor::new_with_logging();
    let scheduler = executor.get_scheduler_handle();

    let _subscription = (1..=3)
        .into_observable()
        .observe_on(scheduler)
        .subscribe(PrintObserver::new("observe_on_operator"));

    executor.tick(Duration::from_millis(1));
}

Output:

Ticking... (0ns)
observe_on_operator - next: 1
observe_on_operator - next: 2
observe_on_operator - next: 3
observe_on_operator - completed
observe_on_operator - unsubscribed