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,
impl<D> ObservableField<D, RefCell<Vec<UniversalSubscriber<D>>>>where
D: 'static,
Sourcepub const fn new(data: D) -> Self
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>,
impl<D, S> ObservableField<D, S>where
D: 'static,
S: Whenable<D>,
Sourcepub fn when<F>(
&self,
assert_fn: F,
) -> LocalBoxFuture<'static, Result<(), DroppedError>>
pub fn when<F>( &self, assert_fn: F, ) -> LocalBoxFuture<'static, Result<(), DroppedError>>
Returns Future which will resolve only on modifications that
the given assert_fn returns true on.
Source§impl<D: 'static> ObservableField<D, SubStore<D>>
impl<D: 'static> ObservableField<D, SubStore<D>>
Sourcepub fn new(data: D) -> Self
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,
impl<D> ObservableField<D, SubStore<D>>where
D: Clone + 'static,
Sourcepub fn subscribe(&self) -> LocalBoxStream<'static, Guarded<D>>
pub fn subscribe(&self) -> LocalBoxStream<'static, Guarded<D>>
Returns Stream into which underlying data updates (wrapped in the
progressable::Guarded) will be emitted.
Sourcepub fn when_all_processed(&self) -> Processed<'static> ⓘ
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>>>>where
D: Clone + 'static,
impl<D> ObservableField<D, RefCell<Vec<UniversalSubscriber<D>>>>where
D: Clone + 'static,
Sourcepub fn subscribe(&self) -> LocalBoxStream<'static, D>
pub fn subscribe(&self) -> LocalBoxStream<'static, D>
Returns Stream into which underlying data updates will be emitted.
Source§impl<D, S> ObservableField<D, S>
impl<D, S> ObservableField<D, S>
Sourcepub fn when_eq(
&self,
should_be: D,
) -> LocalBoxFuture<'static, Result<(), DroppedError>>
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>
impl<D, S> ObservableField<D, S>
Sourcepub fn borrow_mut(&mut self) -> MutObservableFieldGuard<'_, D, S>
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.