| Crates.io | rx_core_observable_combine_latest |
| lib.rs | rx_core_observable_combine_latest |
| version | 0.2.0 |
| created_at | 2026-01-19 07:50:09.276925+00 |
| updated_at | 2026-01-24 15:01:26.359877+00 |
| description | combine_latest observable for rx_core |
| homepage | https://github.com/AlexAegis/rx_bevy |
| repository | https://github.com/AlexAegis/rx_bevy |
| max_upload_size | |
| id | 2053973 |
| size | 18,361 |
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.
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