Skip to main content

ObservableBase

Struct ObservableBase 

Source
pub struct ObservableBase<T> { /* private fields */ }
Expand description

An observable whose subscription is the user’s ObservableCore (ObservableBase<T>).

The observer the core receives ignores everything after a terminal notification, and a terminal notification, or a panic while the observer handles a value, disposes the subscription (AutoDetachObserver<T>). When no work of the current-thread scheduler is running, the subscription runs through its trampoline, so that work it schedules there runs after the subscription has been set up.

Implementations§

Source§

impl<T: 'static> ObservableBase<T>

Source

pub fn new(core: impl ObservableCore<T> + 'static) -> Self

An observable whose subscription is core (a subclass of ObservableBase<T> upstream).

Source

pub fn from_fn( subscribe_core: impl Fn(Rc<dyn IObserver<T>>) -> Rc<dyn IDisposable> + 'static, ) -> Self

An observable whose subscription is the function subscribe_core.

Source

pub fn try_from_fn( subscribe_core: impl Fn(Rc<dyn IObserver<T>>) -> Result<Rc<dyn IDisposable>, ObservableError> + 'static, ) -> Self

An observable whose subscription is the function subscribe_core, which may fail: an Err is delivered to the observer as its error (a SubscribeCore that throws upstream).

Trait Implementations§

Source§

impl<T: 'static> IObservable<T> for ObservableBase<T>

Source§

fn subscribe(&self, observer: Rc<dyn IObserver<T>>) -> Rc<dyn IDisposable>

Subscribes through the core (Subscribe): the observer is wrapped in an auto-detaching observer, which the core receives; an error of the core is delivered to that observer (AutoDetachObserver.Fail), and panics, where upstream rethrows it, when the observer has stopped already.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ObservableBase<T>

§

impl<T> !Send for ObservableBase<T>

§

impl<T> !Sync for ObservableBase<T>

§

impl<T> !UnwindSafe for ObservableBase<T>

§

impl<T> Freeze for ObservableBase<T>
where Rc<dyn ObservableCore<T>>: Freeze,

§

impl<T> Unpin for ObservableBase<T>
where Rc<dyn ObservableCore<T>>: Unpin,

§

impl<T> UnsafeUnpin for ObservableBase<T>
where Rc<dyn ObservableCore<T>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.