Type Alias freya::prelude::EventHandler
pub type EventHandler<T = ()> = Callback<T>;
Expand description
The callback type generated by the rsx!
macro when an on
field is specified for components.
This makes it possible to pass move |evt| {}
style closures into components as property fields.
§Example
rsx!{
MyComponent { onclick: move |evt| tracing::debug!("clicked") }
};
#[derive(Props, Clone, PartialEq)]
struct MyProps {
onclick: EventHandler<MouseEvent>,
}
fn MyComponent(cx: MyProps) -> Element {
rsx!{
button {
onclick: move |evt| cx.onclick.call(evt),
}
}
}
Aliased Type§
struct EventHandler<T = ()> { /* private fields */ }