expression

Broadcast subscriptions start at future events

A receiver created after an event was sent does not replay that event. A separate snapshot or durable event store is needed for initialization or history recovery. Tokio is an external dependency; see the proposed Cargo manifest. Expected stdout (not executed): 1 2 Common mistake: Assuming subscription returns every earlier event still in memory.

Formal Syntax & Structure

rust syntaxrust
tx.subscribe()

Working Example

Example Snippetrust
#[tokio::main(flavor = "current_thread")]async fn main() {    let (tx, mut first) = tokio::sync::broadcast::channel(4);    tx.send(1).unwrap();    let mut late = tx.subscribe();    tx.send(2).unwrap();    println!("{} {}", first.recv().await.unwrap(), late.recv().await.unwrap());}
Rust Reference