EventHandler

Trait EventHandler 

Source
pub trait EventHandler<C, E> {
    // Required method
    fn func(self) -> impl Fn(&mut State<C>, E) + 'static;
}
Expand description

Utility trait for use in stateless components

When defining a stateless component it is much easier to use impl Event<C> than writting out the whole function trait yourself.

fn my_button<C>(click: impl EventHandler<C>) -> impl Element<C> {
    e::button().on("click", click)
}

Required Methods§

Source

fn func(self) -> impl Fn(&mut State<C>, E) + 'static

Return a boxed version of the function in this event

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<C, E, F: Fn(&mut State<C>, E) + 'static> EventHandler<C, E> for F