Struct iced_futures::subscription::Tracker
source · pub struct Tracker { /* private fields */ }
Expand description
A registry of subscription streams.
If you have an application that continuously returns a Subscription
,
you can use a Tracker
to keep track of the different recipes and keep
its executions alive.
Implementations§
source§impl Tracker
impl Tracker
sourcepub fn update<Message, Receiver>(
&mut self,
recipes: impl Iterator<Item = Box<dyn Recipe<Output = Message>>>,
receiver: Receiver
) -> Vec<BoxFuture<()>>
pub fn update<Message, Receiver>( &mut self, recipes: impl Iterator<Item = Box<dyn Recipe<Output = Message>>>, receiver: Receiver ) -> Vec<BoxFuture<()>>
Updates the Tracker
with the given Subscription
.
A Subscription
can cause new streams to be spawned or old streams
to be closed.
The Tracker
keeps track of these streams between calls to this
method:
- If the provided
Subscription
contains a newRecipe
that is currently not being run, it will spawn a new stream and keep it alive. - On the other hand, if a
Recipe
is currently in execution and the providedSubscription
does not contain it anymore, then theTracker
will close and drop the relevant stream.
It returns a list of futures that need to be spawned to materialize
the Tracker
changes.
sourcepub fn broadcast(&mut self, event: Event, status: Status)
pub fn broadcast(&mut self, event: Event, status: Status)
Broadcasts an event to the subscriptions currently alive.
A subscription’s Recipe::stream
always receives a stream of events
as input. This stream can be used by some subscription to listen to
shell events.
This method publishes the given event to all the subscription streams currently open.