rx_core_operator_fallback_when_silent

Crates.iorx_core_operator_fallback_when_silent
lib.rsrx_core_operator_fallback_when_silent
version0.2.0
created_at2026-01-19 14:49:48.02229+00
updated_at2026-01-24 15:06:32.112207+00
descriptionfallback_when_silent operator for rx_core
homepagehttps://github.com/AlexAegis/rx_bevy
repositoryhttps://github.com/AlexAegis/rx_bevy
max_upload_size
id2054741
size21,047
Sandor (AlexAegis)

documentation

https://github.com/AlexAegis/rx_bevy

README

operator_fallback_when_silent

crates.io ci codecov license

Emit a fallback value on ticks where the source stayed silent.

See Also

  • AdsrOperator - Convert trigger signals into an ADSR envelope driven by the scheduler.
  • DelayOperator - Shift emissions forward in time using the scheduler.

Example

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
Commit count: 652

cargo fmt