pub struct Emitter<E: Event> { /* private fields */ }Implementations§
Source§impl<E: Event + 'static> Emitter<E>
impl<E: Event + 'static> Emitter<E>
Sourcepub async fn subscribe<L: Subscriber<E> + 'static>(
&self,
subscriber: L,
) -> &Self
pub async fn subscribe<L: Subscriber<E> + 'static>( &self, subscriber: L, ) -> &Self
Register a subscriber to receive events.
Sourcepub async fn on<L: SubscriberFunc<E> + 'static>(&self, callback: L) -> &Self
pub async fn on<L: SubscriberFunc<E> + 'static>(&self, callback: L) -> &Self
Register a subscriber function to receive events.
Sourcepub async fn once<L: SubscriberFunc<E> + 'static>(&self, callback: L) -> &Self
pub async fn once<L: SubscriberFunc<E> + 'static>(&self, callback: L) -> &Self
Register a subscriber function that will unregister itself after the first event is received. This is useful for one-time event handlers.
Sourcepub async fn emit(&self, event: E) -> Result<E::Data>
pub async fn emit(&self, event: E) -> Result<E::Data>
Emit the provided event to all registered subscribers. Subscribers will be called in the order they were registered.
If a subscriber returns EventState::Stop, no further subscribers will be called.
If a subscriber returns EventState::Continue, the next subscriber will be called.
Auto Trait Implementations§
impl<E> Freeze for Emitter<E>
impl<E> !RefUnwindSafe for Emitter<E>
impl<E> Send for Emitter<E>
impl<E> Sync for Emitter<E>
impl<E> Unpin for Emitter<E>
impl<E> !UnwindSafe for Emitter<E>
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