pub struct ListenerCallback<T = ()> { /* private fields */ }Expand description
An owned callback type used in AttributeValue::Listener.
This is the type that powers the on attributes in the rsx! macro, allowing you to pass event
handlers to elements.
ⓘ
rsx! {
button {
onclick: AttributeValue::Listener(ListenerCallback::new(move |evt: Event<MouseData>| {
// ...
}))
}
}Implementations§
Source§impl<T> ListenerCallback<T>
impl<T> ListenerCallback<T>
Sourcepub fn new<MaybeAsync, Marker>(
f: impl FnMut(Event<T>) -> MaybeAsync + 'static,
) -> Selfwhere
T: 'static,
MaybeAsync: SpawnIfAsync<Marker>,
pub fn new<MaybeAsync, Marker>(
f: impl FnMut(Event<T>) -> MaybeAsync + 'static,
) -> Selfwhere
T: 'static,
MaybeAsync: SpawnIfAsync<Marker>,
Create a new ListenerCallback from a callback
This is expected to be called within a runtime scope. Make sure a runtime is current before calling this method.
Sourcepub fn call(&self, event: Event<dyn Any>)
pub fn call(&self, event: Event<dyn Any>)
Call the callback with an event
This is expected to be called within a runtime scope. Make sure a runtime is current before calling this method.
Sourcepub fn erase(self) -> ListenerCallback
pub fn erase(self) -> ListenerCallback
Erase the type of the callback, allowing it to be used with any type of event
Trait Implementations§
Source§impl<T> Clone for ListenerCallback<T>
impl<T> Clone for ListenerCallback<T>
Source§impl<T> IntoAttributeValue for ListenerCallback<T>
impl<T> IntoAttributeValue for ListenerCallback<T>
Source§fn into_value(self) -> AttributeValue
fn into_value(self) -> AttributeValue
Convert into an attribute value
Source§impl<T> PartialEq for ListenerCallback<T>
impl<T> PartialEq for ListenerCallback<T>
Auto Trait Implementations§
impl<T> Freeze for ListenerCallback<T>
impl<T = ()> !RefUnwindSafe for ListenerCallback<T>
impl<T = ()> !Send for ListenerCallback<T>
impl<T = ()> !Sync for ListenerCallback<T>
impl<T> Unpin for ListenerCallback<T>where
T: Unpin,
impl<T = ()> !UnwindSafe for ListenerCallback<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.