Trait DeepObservable
pub trait DeepObservable: AsRef<Branch> {
// Provided methods
fn observe_deep<F>(&self, f: F) -> Arc<dyn Drop>
where F: Fn(&TransactionMut<'_>, &Events<'_>) + 'static { ... }
fn observe_deep_with<K, F>(&self, key: K, f: F)
where K: Into<Origin>,
F: Fn(&TransactionMut<'_>, &Events<'_>) + 'static { ... }
fn unobserve_deep<K>(&self, key: K) -> bool
where K: Into<Origin> { ... }
}Expand description
Trait implemented by all Y-types, allowing for observing events which are emitted by nested types.
Provided Methods§
fn observe_deep<F>(&self, f: F) -> Arc<dyn Drop>
fn observe_deep<F>(&self, f: F) -> Arc<dyn Drop>
Subscribe a callback f for all events emitted by this and nested collaborative types.
Callback is accepting transaction which triggered that event and event itself, wrapped
within an Event structure.
In case when a nested shared type (e.g. MapRef,ArrayRef,TextRef) is being removed, all of its contents will be removed first. So the observed value will be empty. For example, The value wrapped in the EntryChange::Removed of the Event::Map will be empty.
This method returns a subscription, which will automatically unsubscribe current callback when dropped.
fn observe_deep_with<K, F>(&self, key: K, f: F)
fn observe_deep_with<K, F>(&self, key: K, f: F)
Subscribe a callback f for all events emitted by this and nested collaborative types.
Callback is accepting transaction which triggered that event and event itself, wrapped
within an Event structure.
In case when a nested shared type (e.g. MapRef,ArrayRef,TextRef) is being removed, all of its contents will be removed first. So the observed value will be empty. For example, The value wrapped in the EntryChange::Removed of the Event::Map will be empty.
This method uses a subscription key, which can be later used to cancel this callback via Self::unobserve_deep.
fn unobserve_deep<K>(&self, key: K) -> bool
fn unobserve_deep<K>(&self, key: K) -> bool
Unsubscribe a callback identified by a given key, that was previously subscribed using Self::observe_deep_with.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.