rx_core_observable_combine_latest

Crates.iorx_core_observable_combine_latest
lib.rsrx_core_observable_combine_latest
version0.2.0
created_at2026-01-19 07:50:09.276925+00
updated_at2026-01-24 15:01:26.359877+00
descriptioncombine_latest observable for rx_core
homepagehttps://github.com/AlexAegis/rx_bevy
repositoryhttps://github.com/AlexAegis/rx_bevy
max_upload_size
id2053973
size18,361
Sandor (AlexAegis)

documentation

https://github.com/AlexAegis/rx_bevy

README

observable_combine_latest

crates.io ci codecov license

The CombineLatestObservable subscribes to two input observables, and emits the latest of both values when either of them emits. It only starts emitting once both have emitted at least once.

See Also

  • CombineChangesObservable - Subscribes to two different observables, and emit the latest of both both values when either of them emits. It denotes which one had changed, and it emits even when one on them haven't emitted yet.
  • ZipObservable - Subscribes to two different observables, and emit both values when both of them emits, pairing up emissions by the order they happened.
  • JoinObservable - Subscribes to two different observables, and emit the latest of both values once both of them had completed!

Example

cargo run -p rx_core --example observable_combine_latest_example
let mut greetings_subject = PublishSubject::<&'static str>::default();
let mut count_subject = PublishSubject::<usize>::default();

let mut subscription = combine_latest(
  greetings_subject
    .clone()
    .tap(PrintObserver::new("greetings_subject")),
  count_subject
    .clone()
    .tap(PrintObserver::new("count_subject")),
)
.subscribe(PrintObserver::new("combine_latest"));

greetings_subject.next("Hello!");
count_subject.next(10);
count_subject.next(20);
greetings_subject.next("Szia!");
greetings_subject.complete();
count_subject.next(30);
count_subject.complete();
subscription.unsubscribe();

Output:

greetings_subject - next: "Hello!"
count_subject - next: 10
combine_latest - next: ("Hello!", 10)
count_subject - next: 20
combine_latest - next: ("Hello!", 20)
greetings_subject - next: "Szia!"
combine_latest - next: ("Szia!", 20)
greetings_subject - completed
greetings_subject - unsubscribed
count_subject - next: 30
combine_latest - next: ("Szia!", 30)
count_subject - completed
count_subject - unsubscribed
combine_latest - completed
combine_latest - unsubscribed
Commit count: 652

cargo fmt