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_debounce_time

crates.io ci codecov license

The debounce_time operator emits the most recent upstream value only after the specified duration passes without another emission.

Upstream completion and cancellation can happen instantly if there are no pending debounced values, otherwise it will complete or cancel once the pending debounced value has been emitted.

Upstream errors are immediately propagated downstream, cancelling any pending debounced value.

See Also

Example

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

let mut subject = PublishSubject::<usize>::default();

let _subscription = subject
    .clone()
    .debounce_time(Duration::from_millis(1000), scheduler)
    .subscribe(PrintObserver::new("debounce_time_operator"));

subject.next(1);
executor.tick(Duration::from_millis(500));
subject.next(2);
executor.tick(Duration::from_millis(1000));
subject.complete();

Output:

Ticking... (500ms)
Ticking... (1s)
debounce_time_operator - next: 2
debounce_time_operator - completed
debounce_time_operator - unsubscribed