rx_rust/observable/mod.rs
1pub mod boxed_observable;
2pub mod observable_ext;
3
4use crate::{
5 disposable::subscription::Subscription, observer::Observer, utils::types::NecessarySendSync,
6};
7
8/// The `Observable` trait represents a source of events that can be observed by an `Observer`.
9/// See <https://reactivex.io/documentation/observable.html>
10pub trait Observable<'or, 'sub, T, E> {
11 /// Subscribes an observer to this observable. When an observer is subscribed, it will start receiving events from the observable.
12 /// The `subscribe` method returns a `Subscription` which can be used to unsubscribe the observer from the observable.
13 /// 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.
14 fn subscribe(
15 self,
16 observer: impl Observer<T, E> + NecessarySendSync + 'or,
17 ) -> Subscription<'sub>;
18}