pub struct EventListener { /* private fields */ }Expand description
DOM event listener.
Implementations§
Source§impl EventListener
impl EventListener
Sourcepub fn listen_once<T, F>(target: T, event_type: &str, f: F) -> Self
pub fn listen_once<T, F>(target: T, event_type: &str, f: F) -> Self
Register an event listener that will be called at most once.
Sourcepub fn forget(self)
pub fn forget(self)
Keeps the EventListener alive forever, so it will never be dropped.
This should only be used when you want the EventListener to last
forever, otherwise it will leak memory.
Sourcepub fn target(&self) -> &EventTarget
pub fn target(&self) -> &EventTarget
Returns the EventTarget.
Sourcepub fn event_type(&self) -> &str
pub fn event_type(&self) -> &str
Returns the event type.
Sourcepub fn phase(&self) -> EventPhase
pub fn phase(&self) -> EventPhase
Returns whether the event listener is run during the capture or bubble phase.
The official specification has a good explanation of capturing vs bubbling.
Trait Implementations§
Source§impl Debug for EventListener
impl Debug for EventListener
Auto Trait Implementations§
impl Freeze for EventListener
impl !RefUnwindSafe for EventListener
impl !Send for EventListener
impl !Sync for EventListener
impl Unpin for EventListener
impl !UnwindSafe for EventListener
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