pub struct EventHandler<'bump, T = ()> { /* private fields */ }
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| log::info!("clicked") }
}

#[derive(Props)]
struct MyProps<'a> {
    onclick: EventHandler<'a, MouseEvent>,
}

fn MyComponent(cx: Scope<'a, MyProps<'a>>) -> Element {
    cx.render(rsx!{
        button {
            onclick: move |evt| cx.props.onclick.call(evt),
        }
    })
}

Implementations§

Call this event handler with the appropriate event type

This borrows the event using a RefCell. Recursively calling a listener will cause a panic.

Forcibly drop the internal handler callback, releasing memory

This will force any future calls to “call” to not doing anything

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.