pub struct ObservableField<D, S> { /* private fields */ }
Expand description

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§

source§

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

source

pub const fn new(data: D) -> Self

Returns new ObservableField with subscribable mutations.

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

source§

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

source

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

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

source§

impl<D: 'static> ObservableField<D, SubStore<D>>

source

pub fn new(data: D) -> Self

Returns new ObservableField with subscribable mutations.

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

source§

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

source

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

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

source

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

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

source§

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

source

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

Returns Stream into which underlying data updates will be emitted.

source§

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

source

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

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

source§

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

source

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

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§

source§

impl<D: Debug, S: Debug> Debug for ObservableField<D, S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<D, S> Deref for ObservableField<D, S>

§

type Target = D

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.