Observable

Trait Observable 

Source
pub trait Observable<T: Send + Sync + Clone + 'static> {
    // Required method
    fn subscribe<S: Observer<T> + 'static>(&self, observer: &Arc<S>);

    // Provided methods
    fn poll(&self) -> T { ... }
    fn poll_timeout(&self, duration: Duration) -> Result<T> { ... }
}
Expand description

Event publisher that may be subscribed to

Required Methods§

Source

fn subscribe<S: Observer<T> + 'static>(&self, observer: &Arc<S>)

Adds a weakly held observer

Provided Methods§

Source

fn poll(&self) -> T

Waits indefinitely for an event to be emitted

Source

fn poll_timeout(&self, duration: Duration) -> Result<T>

Waits for an event to be emitted with a timeout

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Send + Sync + Clone + 'static> Observable<T> for Subject<T>

Source§

impl<T: Sync + Send + Clone + 'static> Observable<T> for Single<T>