Skip to main content

UpgradeableObserver

Trait UpgradeableObserver 

Source
pub trait UpgradeableObserver:
    ObserverInput
    + Send
    + Sync {
    type Upgraded: Subscriber<In = Self::In, InError = Self::InError>;

    // Required method
    fn upgrade(self) -> Self::Upgraded;
}
Expand description

When a subscription is established, the destination must only receive the next, error and complete signals, but not unsubscribe. And since subscribers and subjects are observers too, they could be passed as a destination, but doing it naively would always unsubscribe them too when the observable unsubscribes.

To control this behavior, observers can define in what form they should be used when used as a destination.

As a rule of thumb this is how different kind of things should behave:

  • Observer: Must only receive next, error and complete signals. This is only true observers that are only observers. That do not implement SubscriptionLike to become Subscribers.
  • Subjects: Same as Observer. Even though they implement SubscriptionLike, that is meant for external control for the user, and should not be called by upstream.
  • Subscriber: Should forward everything. Subscribers are only used for Pipes and Operators, and they must be fully connected.

To prevent erroneously missing calling upgrade in an Observable’s subscribe function, UpgradeableObserver does NOT have [Observer] as its supertrait!

Required Associated Types§

Source

type Upgraded: Subscriber<In = Self::In, InError = Self::InError>

Required Methods§

Source

fn upgrade(self) -> Self::Upgraded

Implementations on Foreign Types§

Source§

impl<In, ErrorDestination> UpgradeableObserver for WithLatestFromInnerDestination<In, ErrorDestination>
where In: Signal, ErrorDestination: 'static + Subscriber,

Implementors§

Source§

impl<In, InError> UpgradeableObserver for DynFnObserver<In, InError>
where In: Signal, InError: Signal,

Source§

impl<In, InError> UpgradeableObserver for NoopObserver<In, InError>
where In: Signal, InError: Signal,

Source§

impl<In, InError> UpgradeableObserver for BehaviorSubject<In, InError>
where In: Signal + Clone, InError: Signal + Clone,

Source§

impl<In, InError> UpgradeableObserver for PublishSubject<In, InError>
where In: Signal + Clone, InError: Signal + Clone,

Source§

impl<In, InError, OnNext, OnError, OnComplete> UpgradeableObserver for FnObserver<In, InError, OnNext, OnError, OnComplete>
where In: Signal, InError: Signal, OnNext: 'static + FnMut(In) + Send + Sync, OnError: 'static + FnOnce(InError) + Send + Sync, OnComplete: 'static + FnOnce() + Send + Sync,

Source§

type Upgraded = ObserverSubscriber<FnObserver<In, InError, OnNext, OnError, OnComplete>>

Source§

impl<In, InError, Reducer> UpgradeableObserver for AsyncSubject<In, InError, Reducer>
where Reducer: 'static + FnMut(In, In) -> In + Send + Sync, In: Signal + Clone, InError: Signal + Clone,

Source§

type Upgraded = ObserverSubscriber<AsyncSubject<In, InError, Reducer>>

Source§

impl<Provenance, In, InError> UpgradeableObserver for ProvenanceSubject<Provenance, In, InError>
where Provenance: Signal + Clone + PartialEq, In: Signal + Clone, InError: Signal + Clone,

Source§

type Upgraded = ObserverSubscriber<ProvenanceSubject<Provenance, In, InError>>

Source§

impl<T> UpgradeableObserver for T

Source§

impl<const CAPACITY: usize, In, InError> UpgradeableObserver for ReplaySubject<CAPACITY, In, InError>
where In: Signal + Clone, InError: Signal + Clone,

Source§

type Upgraded = ObserverSubscriber<ReplaySubject<CAPACITY, In, InError>>