pub struct OutputListener<T> { /* private fields */ }
Expand description
Listener
implements the emitter side of the [Output Tracking pattern].
Implementations§
Source§impl<T> Listener<T>
impl<T> Listener<T>
Sourcepub fn emit_with(&self, event_source: impl FnMut() -> T)
pub fn emit_with(&self, event_source: impl FnMut() -> T)
Emit a new event to attached listeners.
Calls the given closure to generate the event for each tracker. This allows to skip expensive setup when no trackers are connected.
Sourcepub fn emit_with_cached(&self, cached_event_source: impl FnOnce() -> T)where
T: Clone,
pub fn emit_with_cached(&self, cached_event_source: impl FnOnce() -> T)where
T: Clone,
Emit a new event to attached listeners.
Calls the given closure at most once to generate the event. Afterwards, the generated event is cached and reused for future trackers. This allows to skip expensive setup when no trackers are connected.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Listener<T>
impl<T> !RefUnwindSafe for Listener<T>
impl<T> Send for Listener<T>
impl<T> Sync for Listener<T>
impl<T> Unpin for Listener<T>
impl<T> !UnwindSafe for Listener<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