Struct iced_futures::subscription::Subscription
source · pub struct Subscription<Message> { /* private fields */ }
Expand description
A request to listen to external events.
Besides performing async actions on demand with Command
, most
applications also need to listen to external events passively.
A Subscription
is normally provided to some runtime, like a Command
,
and it will generate events as long as the user keeps requesting it.
For instance, you can use a Subscription
to listen to a WebSocket
connection, keyboard presses, mouse events, time ticks, etc.
Implementations§
source§impl<Message> Subscription<Message>
impl<Message> Subscription<Message>
sourcepub fn none() -> Self
pub fn none() -> Self
Returns an empty Subscription
that will not produce any output.
sourcepub fn from_recipe(recipe: impl Recipe<Output = Message> + 'static) -> Self
pub fn from_recipe(recipe: impl Recipe<Output = Message> + 'static) -> Self
Creates a Subscription
from a Recipe
describing it.
sourcepub fn batch(
subscriptions: impl IntoIterator<Item = Subscription<Message>>
) -> Self
pub fn batch( subscriptions: impl IntoIterator<Item = Subscription<Message>> ) -> Self
Batches all the provided subscriptions and returns the resulting
Subscription
.
sourcepub fn into_recipes(self) -> Vec<Box<dyn Recipe<Output = Message>>>
pub fn into_recipes(self) -> Vec<Box<dyn Recipe<Output = Message>>>
Returns the different recipes of the Subscription
.
sourcepub fn with<T>(self, value: T) -> Subscription<(T, Message)>
pub fn with<T>(self, value: T) -> Subscription<(T, Message)>
Adds a value to the Subscription
context.
The value will be part of the identity of a Subscription
.
sourcepub fn map<F, A>(self, f: F) -> Subscription<A>
pub fn map<F, A>(self, f: F) -> Subscription<A>
Transforms the Subscription
output with the given function.
§Panics
The closure provided must be a non-capturing closure. The method will panic in debug mode otherwise.