Struct seed::virtual_dom::event_handler_manager::EventHandlerManager
source · [−]pub struct EventHandlerManager<Ms> { /* private fields */ }
Expand description
Manages event handlers and listeners for elements.
Implementations
sourceimpl<Ms> EventHandlerManager<Ms>
impl<Ms> EventHandlerManager<Ms>
sourcepub fn with_event_handlers(event_handlers: Vec<EventHandler<Ms>>) -> Self
pub fn with_event_handlers(event_handlers: Vec<EventHandler<Ms>>) -> Self
Creates a new manager instance with given event handlers.
It doesn’t create listeners automatically - you have to call attach_listeners
.
sourcepub fn attach_listeners(
&mut self,
event_target: impl Into<EventTarget> + 'static,
old_manager: Option<&mut EventHandlerManager<Ms>>,
mailbox: &Mailbox<Ms>
)
pub fn attach_listeners(
&mut self,
event_target: impl Into<EventTarget> + 'static,
old_manager: Option<&mut EventHandlerManager<Ms>>,
mailbox: &Mailbox<Ms>
)
Creates missing listeners and attaches them to the given event_target
.
It can reuse listeners from the old_manager
.
sourcepub fn add_event_handlers(&mut self, event_handlers: Vec<EventHandler<Ms>>)
pub fn add_event_handlers(&mut self, event_handlers: Vec<EventHandler<Ms>>)
Add new event handlers into the manager.
It doesn’t create listeners automatically - you have to call attach_listeners
.
sourcepub fn take_and_setup_listener(
&mut self,
trigger: &Ev,
event_handlers: Rc<RefCell<Vec<EventHandler<Ms>>>>
) -> Option<Listener<Ms>>
pub fn take_and_setup_listener(
&mut self,
trigger: &Ev,
event_handlers: Rc<RefCell<Vec<EventHandler<Ms>>>>
) -> Option<Listener<Ms>>
This method is used in attach_listeners
method to move listeners from the old manager.
Trait Implementations
sourceimpl<Ms> Clone for EventHandlerManager<Ms>
impl<Ms> Clone for EventHandlerManager<Ms>
sourceimpl<Ms: Debug> Debug for EventHandlerManager<Ms>
impl<Ms: Debug> Debug for EventHandlerManager<Ms>
sourceimpl<Ms: Default> Default for EventHandlerManager<Ms>
impl<Ms: Default> Default for EventHandlerManager<Ms>
sourcefn default() -> EventHandlerManager<Ms>
fn default() -> EventHandlerManager<Ms>
Returns the “default value” for a type. Read more
sourceimpl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for EventHandlerManager<Ms>
impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for EventHandlerManager<Ms>
sourcefn map_msg(
self,
f: impl FnOnce(Ms) -> OtherMs + 'static + Clone
) -> EventHandlerManager<OtherMs>
fn map_msg(
self,
f: impl FnOnce(Ms) -> OtherMs + 'static + Clone
) -> EventHandlerManager<OtherMs>
Note: Listeners will be automatically detached and removed.
You have to call attach_listeners
to recreate them.
type SelfWithOtherMs = EventHandlerManager<OtherMs>
Auto Trait Implementations
impl<Ms> !RefUnwindSafe for EventHandlerManager<Ms>
impl<Ms> !Send for EventHandlerManager<Ms>
impl<Ms> !Sync for EventHandlerManager<Ms>
impl<Ms> Unpin for EventHandlerManager<Ms>
impl<Ms> !UnwindSafe for EventHandlerManager<Ms>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more