Skip to main content

ObserverExt

Trait ObserverExt 

Source
pub trait ObserverExt<T> {
    // Required methods
    fn to_notifier(&self) -> Box<dyn Fn(Notification<T>)>;
    fn as_observer(&self) -> Rc<dyn IObserver<T>>;
    fn checked(&self) -> Rc<dyn IObserver<T>>;
    fn synchronize(&self) -> Rc<dyn IObserver<T>>;
    fn synchronize_prevent_reentrancy(
        &self,
        prevent_reentrancy: bool,
    ) -> Rc<dyn IObserver<T>>;
    fn synchronize_with_gate(&self, gate: Rc<dyn Any>) -> Rc<dyn IObserver<T>>;
    fn synchronize_with_lock(
        &self,
        async_lock: Rc<AsyncLock>,
    ) -> Rc<dyn IObserver<T>>;
    fn notify_on(&self, scheduler: Rc<dyn IScheduler>) -> Rc<dyn IObserver<T>>;
    fn notify_on_context(
        &self,
        context: Arc<dyn SynchronizationContext>,
    ) -> Rc<dyn IObserver<T>>;
    fn to_progress(&self) -> Rc<dyn IProgress<T>>;
    fn to_progress_on(
        &self,
        scheduler: Rc<dyn IScheduler>,
    ) -> Rc<dyn IProgress<T>>;
}
Expand description

The extension methods of Observer on an observer (Observer.Extensions.cs).

Required Methods§

Source

fn to_notifier(&self) -> Box<dyn Fn(Notification<T>)>

The observer as a function of notifications (ToNotifier).

Source

fn as_observer(&self) -> Rc<dyn IObserver<T>>

An observer that hides the identity of this one (AsObserver).

Source

fn checked(&self) -> Rc<dyn IObserver<T>>

An observer that checks the grammar of the notifications it receives (Checked): it panics, where upstream throws InvalidOperationException, on a notification after a terminal one and on a notification while another is being handled.

Source

fn synchronize(&self) -> Rc<dyn IObserver<T>>

An observer whose notifications reach this one under a lock of its own (Synchronize(IObserver<T>), a SynchronizedObserver<T>): it ignores everything after a terminal notification. On one thread the notifications are serialized already, and the lock of upstream (a monitor) is re-entrant: a notification that re-enters the observer from inside another reaches this one at once.

Source

fn synchronize_prevent_reentrancy( &self, prevent_reentrancy: bool, ) -> Rc<dyn IObserver<T>>

An observer whose notifications reach this one one at a time (Synchronize(IObserver<T>, bool preventReentrancy)): with prevent_reentrancy, through an AsyncLock of its own, so that a notification that re-enters the observer from inside another is queued and reaches this one when that one has returned (AsyncLockObserver<T>); without, as synchronize.

Source

fn synchronize_with_gate(&self, gate: Rc<dyn Any>) -> Rc<dyn IObserver<T>>

An observer whose notifications reach this one under the lock gate (Synchronize(IObserver<T>, object gate)), which observers may share; as synchronize, the lock is re-entrant and has nothing to serialize on one thread. The observer keeps the gate.

Source

fn synchronize_with_lock( &self, async_lock: Rc<AsyncLock>, ) -> Rc<dyn IObserver<T>>

An observer whose notifications reach this one through async_lock (Synchronize(IObserver<T>, AsyncLock), an AsyncLockObserver<T>), which observers may share: a notification that arrives while an action of the lock runs (a re-entrant one) is queued and reaches this one after it.

Source

fn notify_on(&self, scheduler: Rc<dyn IScheduler>) -> Rc<dyn IObserver<T>>

An observer that delivers the notifications to this one on scheduler, in order (NotifyOn(IScheduler)).

Source

fn notify_on_context( &self, context: Arc<dyn SynchronizationContext>, ) -> Rc<dyn IObserver<T>>

An observer that delivers the notifications to this one through context, in order (NotifyOn(SynchronizationContext): the observer of NotifyOn(IScheduler) on a SynchronizationContextScheduler of the context, which posts with post_local: the observer is notified on the thread of the context).

Source

fn to_progress(&self) -> Rc<dyn IProgress<T>>

A progress object whose reports are the values of this observer (ToProgress(IObserver<T>)).

Source

fn to_progress_on(&self, scheduler: Rc<dyn IScheduler>) -> Rc<dyn IProgress<T>>

A progress object whose reports reach this observer as values on scheduler, in order (ToProgress(IObserver<T>, IScheduler), through the observer of ObserveOn).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: 'static> ObserverExt<T> for Rc<dyn IObserver<T>>

Source§

fn to_notifier(&self) -> Box<dyn Fn(Notification<T>)>

Source§

fn as_observer(&self) -> Rc<dyn IObserver<T>>

Source§

fn checked(&self) -> Rc<dyn IObserver<T>>

Source§

fn synchronize(&self) -> Rc<dyn IObserver<T>>

Source§

fn synchronize_prevent_reentrancy( &self, prevent_reentrancy: bool, ) -> Rc<dyn IObserver<T>>

Source§

fn synchronize_with_gate(&self, gate: Rc<dyn Any>) -> Rc<dyn IObserver<T>>

Source§

fn synchronize_with_lock( &self, async_lock: Rc<AsyncLock>, ) -> Rc<dyn IObserver<T>>

Source§

fn notify_on(&self, scheduler: Rc<dyn IScheduler>) -> Rc<dyn IObserver<T>>

Source§

fn notify_on_context( &self, context: Arc<dyn SynchronizationContext>, ) -> Rc<dyn IObserver<T>>

Source§

fn to_progress(&self) -> Rc<dyn IProgress<T>>

Source§

fn to_progress_on(&self, scheduler: Rc<dyn IScheduler>) -> Rc<dyn IProgress<T>>

Implementors§