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_with_latest_from

crates.io ci codecov license

Example

cargo run -p rx_core --example operator_with_latest_from_example
let mut source = PublishSubject::<usize, &'static str>::default();
let mut inner = PublishSubject::<&'static str, &'static str>::default();

let _subscription = source
    .clone()
    .with_latest_from(inner.clone())
    .subscribe(PrintObserver::new("with_latest_from_operator"));

source.next(1);
inner.next("hello");
source.next(2);
source.next(3);
source.next(4);
inner.next("bello");
source.next(5);
inner.error("error");

Output:

with_latest_from_operator - next: (2, "hello")
with_latest_from_operator - next: (3, "hello")
with_latest_from_operator - next: (4, "hello")
with_latest_from_operator - next: (5, "bello")
with_latest_from_operator - error: "error"
with_latest_from_operator - unsubscribed