Expand description
A future-based worker that can consume many inputs and produce many outputs.
§Example
use gloo_worker::reactor::{reactor, ReactorScope};
use gloo_worker::Spawnable;
use futures::{sink::SinkExt, StreamExt};
#[reactor]
async fn SquaredOnDemand(mut scope: ReactorScope<u64, u64>) {
while let Some(m) = scope.next().await {
if scope.send(m.pow(2)).await.is_err() {
break;
}
}
}
let mut bridge = SquaredOnDemand::spawner().spawn("...");
bridge.send_input(2);
assert_eq!(bridge.next().await, Some(4));
assert_eq!(bridge.next().await, None);
Structs§
- Reactor
Bridge - A connection manager for components interaction with oneshot workers.
- Reactor
Registrar - A registrar for reactor workers.
- Reactor
Scope - A handle to communicate with bridges.
- Reactor
Spawner - A spawner to create oneshot workers.
Enums§
- Reactor
Bridge Sink Error - An error type for bridge sink.
Traits§
- Reactor
- A reactor worker.
- Reactor
Scoped - A helper trait to extract the input and output type from a [ReactorStream].
Attribute Macros§
- reactor
- Creates a reactor worker.