pub struct EventSource<T: ForLifetime> { /* private fields */ }
Expand description
Event source
Implementations§
Source§impl<T: ForLifetime> EventSource<T>
impl<T: ForLifetime> EventSource<T>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create new EventSource
Sourcepub fn with_emitter(&self, emit_fn: impl FnOnce(EventEmitter<'_, T>))
pub fn with_emitter(&self, emit_fn: impl FnOnce(EventEmitter<'_, T>))
Create EventEmitter
for this EventSource
Sourcepub fn on<F>(&self, listener: F) -> EventFnFuture<'_, F, T> ⓘ
pub fn on<F>(&self, listener: F) -> EventFnFuture<'_, F, T> ⓘ
Listen events
It can be called after woken if another event occurred before task continue
Sourcepub async fn once<F, R>(&self, listener: F) -> Option<R>
pub async fn once<F, R>(&self, listener: F) -> Option<R>
Listen event until listener returns Option::Some
Unlike EventSource::on
it will ignore every events once listener is done or returns with Option::Some
.
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