Struct medea_reactive::ObservableField [−][src]
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]
D: 'static,
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]
D: 'static,
S: Whenable<D>,
pub fn when<F>(
&self,
assert_fn: F
) -> LocalBoxFuture<'static, Result<(), DroppedError>> where
F: Fn(&D) -> bool + 'static,
[src]
&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.
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]
D: Clone + 'static,
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>ⓘ
[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]
D: Clone + 'static,
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]
D: PartialEq + 'static,
S: Whenable<D>,
pub fn when_eq(
&self,
should_be: D
) -> LocalBoxFuture<'static, Result<(), DroppedError>>
[src]
&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.
impl<D, S> ObservableField<D, S> where
S: OnObservableFieldModification<D>,
D: Clone + PartialEq,
[src]
S: OnObservableFieldModification<D>,
D: Clone + PartialEq,
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]
impl<D, S> Display for ObservableField<D, S> where
D: Display,
[src]
D: Display,
Auto Trait Implementations
impl<D, S> RefUnwindSafe for ObservableField<D, S> where
D: RefUnwindSafe,
S: RefUnwindSafe,
D: RefUnwindSafe,
S: RefUnwindSafe,
impl<D, S> Send for ObservableField<D, S> where
D: Send,
S: Send,
D: Send,
S: Send,
impl<D, S> Sync for ObservableField<D, S> where
D: Sync,
S: Sync,
D: Sync,
S: Sync,
impl<D, S> Unpin for ObservableField<D, S> where
D: Unpin,
S: Unpin,
D: Unpin,
S: Unpin,
impl<D, S> UnwindSafe for ObservableField<D, S> where
D: UnwindSafe,
S: UnwindSafe,
D: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,