pub struct ReactiveCell<T> { /* private fields */ }Expand description
A reactive value you can read, write and subscribe to, with the primitive behind it erased - along with its type parameters, so fields, map entries and in-memory values share one type and one collection.
Writes always reach where the value lives.
Implementations§
Source§impl<T> ReactiveCell<T>
impl<T> ReactiveCell<T>
pub fn get(&self) -> T
Sourcepub fn durable(&self) -> Durable<'_, Self>
pub fn durable(&self) -> Durable<'_, Self>
The same writes, each returning only once the value is on disk.
A cell over a value held in memory has nothing to commit to, and its writes here behave as the plain ones do.
Sourcepub fn set(&self, value: T) -> WriteResult<()>
pub fn set(&self, value: T) -> WriteResult<()>
Fails if the write is refused - by an interceptor, or by the store.
The cache is left to the store subscription, so a refused write never
shows up in get().
Sourcepub fn update<F>(&self, f: F) -> WriteResult<T>where
F: FnOnce(T) -> T,
pub fn update<F>(&self, f: F) -> WriteResult<T>where
F: FnOnce(T) -> T,
Read-modify-write, not atomic.
Sourcepub fn modify<F>(&self, f: F) -> WriteResult<()>
pub fn modify<F>(&self, f: F) -> WriteResult<()>
Same caveat as ReactiveCell::update: read-modify-write, not atomic.
pub fn subscribe<F>(&self, callback: F) -> SignalSubscription
Sourcepub fn subscribe_with_source<F>(&self, callback: F) -> SignalSubscription
pub fn subscribe_with_source<F>(&self, callback: F) -> SignalSubscription
Subscribes with the provenance of each change, so a subscriber can tell its own writes from everyone else’s.
Sourcepub fn subscription_with(&self) -> Watch<Self, Immediate>
pub fn subscription_with(&self) -> Watch<Self, Immediate>
Configures a subscription: filtering, provenance, and where the callback
runs. See Watch.
Trait Implementations§
Source§impl<T> Clone for ReactiveCell<T>
impl<T> Clone for ReactiveCell<T>
Source§impl<T> Reactive<T> for ReactiveCell<T>
impl<T> Reactive<T> for ReactiveCell<T>
Source§impl<T> Watchable for ReactiveCell<T>
impl<T> Watchable for ReactiveCell<T>
fn watch_raw<F>(&self, callback: F) -> SignalSubscription
Source§fn filterable(_item: &Self::Item) -> bool
fn filterable(_item: &Self::Item) -> bool
Watch::external may drop this item when it came from this
handle. Read more