| Crates.io | rx_core_operator_fallback_when_silent |
| lib.rs | rx_core_operator_fallback_when_silent |
| version | 0.2.0 |
| created_at | 2026-01-19 14:49:48.02229+00 |
| updated_at | 2026-01-24 15:06:32.112207+00 |
| description | fallback_when_silent operator for rx_core |
| homepage | https://github.com/AlexAegis/rx_bevy |
| repository | https://github.com/AlexAegis/rx_bevy |
| max_upload_size | |
| id | 2054741 |
| size | 21,047 |
Emit a fallback value on ticks where the source stayed silent.
cargo run -p rx_core --example operator_fallback_when_silent_example
use std::time::Duration;
use rx_core::prelude::*;
use rx_core_testing::MockExecutor;
fn main() {
let mut executor = MockExecutor::default();
let scheduler = executor.get_scheduler_handle();
let mut subject = PublishSubject::<i32>::default();
let mut subscription = subject
.clone()
.fallback_when_silent(|_, _, _| Default::default(), scheduler)
.subscribe(PrintObserver::<i32>::new("fallback_when_silent"));
subject.next(1);
executor.tick(Duration::from_millis(200));
subject.next(2);
executor.tick(Duration::from_millis(200));
// Silence
executor.tick(Duration::from_millis(200));
subject.next(3);
executor.tick(Duration::from_millis(200));
subscription.unsubscribe();
}
fallback_when_silent - next: 1
fallback_when_silent - next: 2
fallback_when_silent - next: 0
fallback_when_silent - next: 3
fallback_when_silent - unsubscribed