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_finalize

crates.io ci codecov license

Execute cleanup when the observable finishes or unsubscribes.

See Also

  • TapOperator - Mirror all signals into another observer.
  • TapNextOperator - Run a callback for each next value while letting signals pass through.
  • OnNextOperator - Invoke a callback for each value that can also decide whether to forward it.
  • OnSubscribeOperator - Run a callback when a subscription is established.

Example

cargo run -p rx_core --example operator_finalize_completion_example
let _subscription = just(12)
    .finalize(|| println!("finally!"))
    .subscribe(PrintObserver::new("finalize_operator"));

Output:

finalize_operator - next: 12
finalize_operator - completed
finally!
finalize_operator - unsubscribed