Struct sauron_core::dom::cmd::Cmd
source · pub struct Cmd<APP, MSG>where
MSG: 'static,{
pub commands: Vec<Box<dyn FnOnce(Program<APP, MSG>)>>,
/* private fields */
}
Expand description
Cmd is a command to be executed by the system. This is returned at the init function of a component and is executed right after instantiation of that component. Cmd required a DSP object which is the Program as an argument The emit function is called with the program argument. The callback is supplied with the program an is then executed/emitted.
Fields§
§commands: Vec<Box<dyn FnOnce(Program<APP, MSG>)>>
the functions that would be executed when this Cmd is emited
Implementations§
source§impl<APP, MSG> Cmd<APP, MSG>where
MSG: 'static,
APP: Application<MSG> + 'static,
impl<APP, MSG> Cmd<APP, MSG>where MSG: 'static, APP: Application<MSG> + 'static,
sourcepub fn new<F>(f: F) -> Selfwhere
F: FnOnce(Program<APP, MSG>) + 'static,
pub fn new<F>(f: F) -> Selfwhere F: FnOnce(Program<APP, MSG>) + 'static,
creates a new Cmd from a function
sourcepub fn batch(cmds: impl IntoIterator<Item = Self>) -> Self
pub fn batch(cmds: impl IntoIterator<Item = Self>) -> Self
When you need the runtime to perform couple of commands, you can batch then together.
sourcepub fn append(&mut self, cmds: impl IntoIterator<Item = Self>)
pub fn append(&mut self, cmds: impl IntoIterator<Item = Self>)
Append more cmd into this cmd and return self
sourcepub fn should_update_view(self, should_update_view: bool) -> Self
pub fn should_update_view(self, should_update_view: bool) -> Self
Modify the Cmd such that whether or not it will update the view set by should_update_view
when the cmd is executed in the program
sourcepub fn no_render(self) -> Self
pub fn no_render(self) -> Self
Modify the command such that it will not do an update on the view when it is executed.
sourcepub fn measure(self) -> Self
pub fn measure(self) -> Self
Modify the command such that it will log measurement when it is executed
sourcepub fn measure_with_name(self, name: &str) -> Self
pub fn measure_with_name(self, name: &str) -> Self
Modify the Cmd such that it will log a measuregment when it is executed
The measurement_name
is set to distinguish the measurements from each other.
sourcepub fn batch_msg(msg_list: impl IntoIterator<Item = MSG>) -> Self
pub fn batch_msg(msg_list: impl IntoIterator<Item = MSG>) -> Self
Tell the runtime to execute subsequent update of the App with the message list. A single call to update the view is then executed thereafter.