pub enum EventHandler {
DispatchState(String),
CallWasm {
function: String,
args: Vec<String>,
},
PostMessage {
worker: String,
message_type: String,
fields: Vec<(String, String)>,
},
UpdateElement {
selector: String,
property: String,
value: String,
},
ToggleClass {
selector: String,
class: String,
},
PreventDefault,
Chain(Vec<EventHandler>),
If {
condition: String,
then: Box<EventHandler>,
otherwise: Option<Box<EventHandler>>,
},
}Expand description
Event handler action
Variants§
DispatchState(String)
Dispatch a state change event
CallWasm
Call a WASM exported function
PostMessage
Post a message to a worker
Fields
UpdateElement
Update a DOM element
Fields
ToggleClass
Toggle a CSS class
PreventDefault
Prevent default and stop propagation
Chain(Vec<EventHandler>)
Chain multiple handlers
If
Conditional handler
Fields
§
then: Box<EventHandler>Handler if true
§
otherwise: Option<Box<EventHandler>>Handler if false (optional)
Implementations§
Source§impl EventHandler
impl EventHandler
Sourcepub fn dispatch_state(state: impl Into<String>) -> Self
pub fn dispatch_state(state: impl Into<String>) -> Self
Create a state dispatch handler
Sourcepub fn call_wasm_with_args(
function: impl Into<String>,
args: Vec<String>,
) -> Self
pub fn call_wasm_with_args( function: impl Into<String>, args: Vec<String>, ) -> Self
Create a WASM call handler with arguments
Sourcepub fn post_to_worker(
worker: impl Into<String>,
message_type: impl Into<String>,
) -> Self
pub fn post_to_worker( worker: impl Into<String>, message_type: impl Into<String>, ) -> Self
Create a worker message handler
Sourcepub fn update_element(
selector: impl Into<String>,
property: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn update_element( selector: impl Into<String>, property: impl Into<String>, value: impl Into<String>, ) -> Self
Create an element update handler
Sourcepub fn toggle_class(
selector: impl Into<String>,
class: impl Into<String>,
) -> Self
pub fn toggle_class( selector: impl Into<String>, class: impl Into<String>, ) -> Self
Create a class toggle handler
Sourcepub fn chain(handlers: Vec<EventHandler>) -> Self
pub fn chain(handlers: Vec<EventHandler>) -> Self
Chain handlers
Sourcepub fn when(
condition: impl Into<String>,
then: EventHandler,
otherwise: Option<EventHandler>,
) -> Self
pub fn when( condition: impl Into<String>, then: EventHandler, otherwise: Option<EventHandler>, ) -> Self
Create a conditional handler
Trait Implementations§
Source§impl Clone for EventHandler
impl Clone for EventHandler
Source§fn clone(&self) -> EventHandler
fn clone(&self) -> EventHandler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EventHandler
impl RefUnwindSafe for EventHandler
impl Send for EventHandler
impl Sync for EventHandler
impl Unpin for EventHandler
impl UnsafeUnpin for EventHandler
impl UnwindSafe for EventHandler
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more