pub type Handler<A: Clone + 'static> = Box<dyn FnMut(&A) -> HandlerResult + Send + 'static>;Expand description
Represents a handler in a widget context.
There are different flavors of handlers, you can use macros to declare then.
See hn!, hn_once! or async_hn!, async_hn_once! to start.
§Type Inference Limitations
This type is not a full struct because the closure args type inference only works with Box, if this was
a full struct all handler declarations that use the args would have to declare the args type.
Methods for this type are implemented in HandlerExt. Also note that the A type must be Clone + 'static,
unfortunately Rust does not enforce bounds in type alias.
Aliased Type§
pub struct Handler<A: Clone + 'static>(/* private fields */);Trait Implementations§
Source§impl<A: Clone + 'static> From<ArcHandler<A>> for Handler<A>
impl<A: Clone + 'static> From<ArcHandler<A>> for Handler<A>
Source§fn from(f: ArcHandler<A>) -> Self
fn from(f: ArcHandler<A>) -> Self
Converts to this type from the input type.
Source§impl<A: Clone + 'static> HandlerExt<A> for Handler<A>
impl<A: Clone + 'static> HandlerExt<A> for Handler<A>
Source§fn widget_event(&mut self, args: &A) -> Option<UiTask<()>>
fn widget_event(&mut self, args: &A) -> Option<UiTask<()>>
Notify the handler in a widget context. Read more
Source§fn app_event(
&mut self,
handle: Box<dyn AppWeakHandle>,
is_preview: bool,
args: &A,
)
fn app_event( &mut self, handle: Box<dyn AppWeakHandle>, is_preview: bool, args: &A, )
Notify the handler outside of any widget or window context, inside a
APP_HANDLER context. Read moreSource§fn filtered(self, filter: impl FnMut(&A) -> bool + Send + 'static) -> Self
fn filtered(self, filter: impl FnMut(&A) -> bool + Send + 'static) -> Self
New handler that only calls for arguments approved by
filter.Source§fn into_arc(self) -> ArcHandler<A>
fn into_arc(self) -> ArcHandler<A>
Into cloneable handler. Read more
Source§fn into_wgt_runner(self) -> WidgetRunner<A>
fn into_wgt_runner(self) -> WidgetRunner<A>
Wrap the handler into a type that implements the async task management in an widget context.