pub struct EventSource<T> { /* private fields */ }
Expand description
Emits events to subscribed listeners.
Implementations§
source§impl<T: Clone + Copy + 'static> EventSource<T>
impl<T: Clone + Copy + 'static> EventSource<T>
pub fn new() -> Self
sourcepub fn add_listener(
&mut self,
notify_fn: impl Fn(T, &mut CallbackQueue) + Send + Sync + 'static,
) -> Handle<T>
pub fn add_listener( &mut self, notify_fn: impl Fn(T, &mut CallbackQueue) + Send + Sync + 'static, ) -> Handle<T>
Add a listener.
sourcepub fn notify_listeners(&mut self, message: T, cb_queue: &mut CallbackQueue)
pub fn notify_listeners(&mut self, message: T, cb_queue: &mut CallbackQueue)
Notify all listeners.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for EventSource<T>
impl<T> !RefUnwindSafe for EventSource<T>
impl<T> Send for EventSource<T>
impl<T> Sync for EventSource<T>
impl<T> Unpin for EventSource<T>
impl<T> !UnwindSafe for EventSource<T>
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> 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