Struct medea_reactive::ObservableField[][src]

pub struct ObservableField<D, S> { /* fields omitted */ }

Reactive cell which emits all modifications to its subscribers.

Subscribing to this field modifications is done with ObservableField::subscribe method.

If you want to get Future which will resolved only when an underlying data of this field will become equal to some value, you can use ObservableField::when or ObservableField::when_eq methods.

Implementations

impl<D> ObservableField<D, RefCell<Vec<UniversalSubscriber<D>>>> where
    D: 'static, 
[src]

pub fn new(data: D) -> Self[src]

Returns new ObservableField with subscribable mutations.

Also you can subscribe to concrete mutations with ObservableField::when and ObservableField::when_eq methods.

impl<D, S> ObservableField<D, S> where
    D: 'static,
    S: Whenable<D>, 
[src]

pub fn when<F>(
    &self,
    assert_fn: F
) -> LocalBoxFuture<'static, Result<(), DroppedError>> where
    F: Fn(&D) -> bool + 'static, 
[src]

Returns Future which will resolve only on modifications that the given assert_fn returns true on.

impl<D: 'static> ObservableField<D, SubStore<D>>[src]

pub fn new(data: D) -> Self[src]

Returns new ObservableField with subscribable mutations.

Also, you can wait for all updates processing by awaiting on ObservableField::when_all_processed().

impl<D> ObservableField<D, SubStore<D>> where
    D: Clone + 'static, 
[src]

pub fn subscribe(&self) -> LocalBoxStream<'static, Guarded<D>>[src]

Returns Stream into which underlying data updates (wrapped in the progressable::Guarded) will be emitted.

pub fn when_all_processed(&self) -> Processed<'static>

Notable traits for Processed<'a, T>

impl<'a, T> Future for Processed<'a, T> type Output = T;
[src]

Returns Future resolving when all data updates will be processed by subscribers.

impl<D> ObservableField<D, RefCell<Vec<UniversalSubscriber<D>, Global>>> where
    D: Clone + 'static, 
[src]

pub fn subscribe(&self) -> LocalBoxStream<'static, D>[src]

Returns Stream into which underlying data updates will be emitted.

impl<D, S> ObservableField<D, S> where
    D: PartialEq + 'static,
    S: Whenable<D>, 
[src]

pub fn when_eq(
    &self,
    should_be: D
) -> LocalBoxFuture<'static, Result<(), DroppedError>>
[src]

Returns Future which will resolve only when an underlying data of this ObservableField will become equal to the provided should_be value.

impl<D, S> ObservableField<D, S> where
    S: OnObservableFieldModification<D>,
    D: Clone + PartialEq
[src]

pub fn borrow_mut(&mut self) -> MutObservableFieldGuard<'_, D, S>[src]

Returns MutObservableFieldGuard which can be mutably dereferenced to an underlying data.

If some mutation of data happens between calling ObservableField::borrow_mut and dropping of MutObservableFieldGuard, then all subscribers of this ObservableField will be notified about this.

Notification about mutation will be sent only if this field really changed. This will be checked with PartialEq implementation of underlying data.

Trait Implementations

impl<D: Debug, S: Debug> Debug for ObservableField<D, S>[src]

impl<D, S> Deref for ObservableField<D, S>[src]

type Target = D

The resulting type after dereferencing.

impl<D, S> Display for ObservableField<D, S> where
    D: Display
[src]

Auto Trait Implementations

impl<D, S> RefUnwindSafe for ObservableField<D, S> where
    D: RefUnwindSafe,
    S: RefUnwindSafe

impl<D, S> Send for ObservableField<D, S> where
    D: Send,
    S: Send

impl<D, S> Sync for ObservableField<D, S> where
    D: Sync,
    S: Sync

impl<D, S> Unpin for ObservableField<D, S> where
    D: Unpin,
    S: Unpin

impl<D, S> UnwindSafe for ObservableField<D, S> where
    D: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.