pub trait Observable<'or, 'sub, T, E> {
// Required method
fn subscribe(
self,
observer: impl Observer<T, E> + NecessarySendSync + 'or,
) -> Subscription<'sub>;
}Expand description
The Observable trait represents a source of events that can be observed by an Observer.
See https://reactivex.io/documentation/observable.html
Required Methods§
Sourcefn subscribe(
self,
observer: impl Observer<T, E> + NecessarySendSync + 'or,
) -> Subscription<'sub>
fn subscribe( self, observer: impl Observer<T, E> + NecessarySendSync + 'or, ) -> Subscription<'sub>
Subscribes an observer to this observable. When an observer is subscribed, it will start receiving events from the observable.
The subscribe method returns a Subscription which can be used to unsubscribe the observer from the observable.
We use Subscription struct instead of trait like impl Cancellable, because we need to cancel the subscription when the Subscription is dropped. It’s not possible to implement Drop for a trait object.
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.