pub struct CallbackHolder<F: ?Sized + 'static = dyn FnMut()> { /* private fields */ }Expand description
Keeps a composable’s callback parameter across recompositions: its forwarders always call the
callback stored last. F is the callback’s trait object, as dyn FnMut(usize).
Implementations§
Source§impl<F: ?Sized + 'static> CallbackHolder<F>
impl<F: ?Sized + 'static> CallbackHolder<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
A holder with no callback yet; its forwarders do nothing until one is stored.
Sourcepub fn update_boxed(&self, callback: Box<F>)
pub fn update_boxed(&self, callback: Box<F>)
Stores callback in place of the one stored last. Generated composable helpers take
callbacks type-erased at the public-fn boundary, so helper bodies are compiled once
instead of once per caller closure type.
Sourcepub fn renders(&self) -> bool
pub fn renders(&self) -> bool
Whether the callback ever ran outside an event handler or an effect: during composition, layout or drawing. A call whose other parameters are unchanged skips its body when its new callbacks never did, because its forwarders call the new ones.
Sourcepub fn forwarder(&self) -> CallbackForwarder<F>
pub fn forwarder(&self) -> CallbackForwarder<F>
The handle a forwarder closure calls the stored callback through.