pub struct Event<A>where
A: ?Sized,{ /* private fields */ }Expand description
A multicast event of a model object: the equivalent of a managed event
member on a type that is not part of the class hierarchy.
Handlers are identified by the token returned from add.
Raising works on a snapshot, so handlers may add or remove handlers.
Implementations§
Source§impl<A> Event<A>where
A: ?Sized,
impl<A> Event<A>where
A: ?Sized,
pub fn new() -> Event<A>
An event whose handler tokens come from ids, a counter shared with
other handler lists (see HandlerList::with_shared_ids).
Sourcepub fn with_ordered_ids() -> Event<A>
pub fn with_ordered_ids() -> Event<A>
An event whose handler tokens come from the counter of the process
(see HandlerList::with_ordered_ids).
Sourcepub fn snapshot(&self) -> HandlerSnapshot<dyn Fn(&A)>
pub fn snapshot(&self) -> HandlerSnapshot<dyn Fn(&A)>
The current handlers with their tokens; later changes do not affect it.
Sourcepub fn add(&self, handler: Rc<dyn Fn(&A)>) -> u64
pub fn add(&self, handler: Rc<dyn Fn(&A)>) -> u64
Adds a handler; returns the token that removes it.
Sourcepub fn remove(&self, token: u64) -> bool
pub fn remove(&self, token: u64) -> bool
Removes a handler. Returns false if the token is unknown.
Sourcepub fn has_handlers(&self) -> bool
pub fn has_handlers(&self) -> bool
Whether any handler is subscribed.
Sourcepub fn handler_count(&self) -> usize
pub fn handler_count(&self) -> usize
The number of subscribed handlers.
Trait Implementations§
Auto Trait Implementations§
impl<A> !Freeze for Event<A>
impl<A> !RefUnwindSafe for Event<A>
impl<A> !Send for Event<A>
impl<A> !Sync for Event<A>
impl<A> !UnwindSafe for Event<A>
impl<A> Unpin for Event<A>
impl<A> UnsafeUnpin for Event<A>
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> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
The static constructor of a type: work done once per thread, after
the properties of the type are registered and before its first
instance exists (class handlers,
affects_render, metadata
overrides). Read more