Function just_watch::channel
source · pub fn channel<T>(init: T) -> (Sender<T>, Receiver<T>)
Expand description
Creates a new watch channel, returning the “send” and “receive” handles.
All values sent by Sender
will become visible to the Receiver
handles.
Only the last value sent is made available to the Receiver
half. All
intermediate values are dropped.
Examples
let (tx, mut rx) = just_watch::channel("hello");
executor.spawn(async move {
while let Ok(value) = rx.recv().await {
println!("received = {:?}", value);
}
});
tx.send("world").unwrap();