rx_core_subject_replay

Crates.iorx_core_subject_replay
lib.rsrx_core_subject_replay
version0.2.0
created_at2026-01-19 21:18:35.670354+00
updated_at2026-01-24 15:11:35.260782+00
descriptionreplat_subject for rx_core
homepagehttps://github.com/AlexAegis/rx_bevy
repositoryhttps://github.com/AlexAegis/rx_bevy
max_upload_size
id2055384
size13,041
Sandor (AlexAegis)

documentation

https://github.com/AlexAegis/rx_bevy

README

subject_replay

crates.io ci codecov license

Buffers the last N values and replays them to late subscribers.

See Also

  • PublishSubject - Forwards observed signals to active subscribers without replaying values, but terminal state is replayed.
  • AsyncSubject - Reduces observed values into one and emits it on completion, replaying the result to late subscribers.
  • BehaviorSubject - Always holds a value that is replayed to late subscribers.
  • ProvenanceSubject - BehaviorSubject that also stores an additional filtering value to track provenance.

Example

cargo run -p rx_core --example subject_replay_example
use rx_core::prelude::*;

fn main() {
    let mut subject = ReplaySubject::<2, i32>::default();

    let _s = subject
        .clone()
        .subscribe(PrintObserver::<i32>::new("hello"));

    subject.next(1);
    subject.next(2);
    subject.next(3);

    let _s2 = subject
        .clone()
        .subscribe(PrintObserver::<i32>::new("hi"));

    subject.next(4);
    subject.next(5);
}

Output:

hello - next: 1
hello - next: 2
hello - next: 3
hi - next: 2
hi - next: 3
hi - next: 4
hello - next: 4
hi - next: 5
hello - next: 5
hi - unsubscribed
hello - unsubscribed
Commit count: 652

cargo fmt