Skip to main content

Observable

Struct Observable 

Source
pub struct Observable;
Expand description

Factory functions for observables.

Implementations§

Source§

impl Observable

Source

pub fn create<T: 'static>( subscribe: impl Fn(Rc<dyn IObserver<T>>) -> Rc<dyn IDisposable> + 'static, ) -> Rc<dyn IObservable<T>>

Creates an observable from a subscribe function.

Source

pub fn return_<T: Clone + 'static>(value: T) -> Rc<dyn IObservable<T>>

An observable that produces a single value and completes.

Source

pub fn single_value<T: Clone + 'static>(value: T) -> Rc<dyn IObservable<T>>

An observable that produces a single value and never completes.

Source

pub fn never<T: 'static>() -> Rc<dyn IObservable<T>>

An observable that never produces a value.

Source

pub fn empty<T: 'static>() -> Rc<dyn IObservable<T>>

An observable that completes immediately.

Source

pub fn switch<TSource: 'static>( sources: Rc<dyn IObservable<Rc<dyn IObservable<TSource>>>>, ) -> Rc<dyn IObservable<TSource>>

Forwards the values of the most recent of the observables that sources produces.

Source

pub fn combine_latest_all<TInput: Clone + 'static>( inputs: impl IntoIterator<Item = Rc<dyn IObservable<TInput>>>, ) -> Rc<dyn IObservable<Vec<TInput>>>

Combines the latest values of a sequence of observables: once every one of them has produced a value, each new value produces the list of the latest ones.

Source

pub fn from_event_pattern<T: Clone + 'static>( add_handler: impl Fn(Rc<dyn Fn(&T)>) -> Rc<dyn IDisposable> + 'static, ) -> Rc<dyn IObservable<T>>

An observable of the arguments of an event.

add_handler adds the handler it is given to the event and returns the handle that removes it, as the events of this crate do (the original takes one function to add and one to remove a handler, for events with and without typed arguments).

Auto Trait Implementations§

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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.