rx_core_subject_async

Crates.iorx_core_subject_async
lib.rsrx_core_subject_async
version0.2.0
created_at2026-01-19 20:51:04.256174+00
updated_at2026-01-24 15:10:59.910747+00
descriptionasync_subject for rx_core
homepagehttps://github.com/AlexAegis/rx_bevy
repositoryhttps://github.com/AlexAegis/rx_bevy
max_upload_size
id2055330
size16,393
Sandor (AlexAegis)

documentation

https://github.com/AlexAegis/rx_bevy

README

subject_async

crates.io ci codecov license

Reduces observed values into one and emits it to active subscribers once completed. Once completed, it also replays the result to late subscribers.

See Also

  • PublishSubject - Forwards observed signals to active subscribers without replaying values, but terminal state is replayed.
  • BehaviorSubject - Always holds a value that is replayed to late subscribers.
  • ReplaySubject - Buffers the last N values and replays them to late subscribers.
  • ProvenanceSubject - BehaviorSubject that also stores an additional filtering value to track provenance.

Example

Run the example with:

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

fn main() {
    let mut subject = AsyncSubject::<i32>::default();

    let mut _subscription_1 = subject
        .clone()
        .subscribe(PrintObserver::<i32>::new("async_subject sub_1"));

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

    let mut _subscription_2 = subject
        .clone()
        .subscribe(PrintObserver::<i32>::new("async_subject sub_2"));

    subject.next(3);
    subject.complete();

    let mut _subscription_3 = subject
        .clone()
        .subscribe(PrintObserver::<i32>::new("async_subject sub_3"));
}

Output:

async_subject sub_1 - next: 3
async_subject sub_2 - next: 3
async_subject sub_1 - completed
async_subject sub_1 - unsubscribed
async_subject sub_2 - completed
async_subject sub_2 - unsubscribed
async_subject sub_3 - next: 3
async_subject sub_3 - completed
async_subject sub_3 - unsubscribed
Commit count: 652

cargo fmt