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_zip

crates.io ci codecov license

Subscribes to two observables, emitting paired tuples when both have emitted, matching them in emission order.

See Also

  • CombineChangesObservable - Emits the latest of two sources, tagging which side changed, even before both have emitted.
  • CombineLatestObservable - Emits the latest of two sources whenever either emits, after both emitted at least once.
  • JoinObservable - Emits the last values from both sources once both have completed.

Example

cargo run -p rx_core --example observable_zip_example
let observable_1 = (1..=3).into_observable();
let observable_2 = (4..=6).into_observable();

let _subscription = zip(observable_1, observable_2)
    .subscribe(PrintObserver::new("zip_observable"));

Output:

zip_observable - next: (1, 4)
zip_observable - next: (2, 5)
zip_observable - next: (3, 6)
zip_observable - completed
zip_observable - unsubscribed