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_concat

crates.io ci codecov license

Combine many observables of the same output type into one by subscribing to them sequentially in order.

See Also

  • MergeObservable - Combine many observables of the same output type by subscribing to all of them at once.

Example

cargo run -p rx_core --example observable_concat_example
let mut subject_1 = PublishSubject::<usize>::default();
let mut subject_2 = PublishSubject::<usize>::default();
let mut subject_3 = PublishSubject::<usize>::default();

let _subscription = concat((
  subject_1.clone(),
  subject_2.clone().take(2),
  subject_3.clone(),
))
.subscribe(PrintObserver::new("concat_operator"));

subject_1.next(1);
subject_1.complete();
subject_3.complete();
subject_2.next(2);
subject_2.next(3);

Output:

concat_operator - next: 1
concat_operator - next: 2
concat_operator - next: 3
concat_operator - completed
concat_operator - unsubscribed