Trait yrs::types::DeepObservable

source ·
pub trait DeepObservable {
    // Required methods
    fn observe_deep<F>(&mut self, f: F) -> DeepEventsSubscription
       where F: Fn(&TransactionMut<'_>, &Events) + 'static;
    fn unobserve_deep(&mut self, subscription_id: SubscriptionId);
}
Expand description

Trait implemented by all Y-types, allowing for observing events which are emitted by nested types.

Required Methods§

source

fn observe_deep<F>(&mut self, f: F) -> DeepEventsSubscriptionwhere F: Fn(&TransactionMut<'_>, &Events) + 'static,

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.

source

fn unobserve_deep(&mut self, subscription_id: SubscriptionId)

Unobserves callback identified by subscription_id (which can be obtained by consuming Subscription using into cast).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> DeepObservable for Twhere T: AsMut<Branch>,