reactive_graph_behaviour_model_api/
observer.rs

1use serde_json::Value;
2
3/// A PropertyObserverContainer manages the observers of a PropertyContainer.
4///
5/// Internally it stores the handle ids of created observers. This makes it possible to remove the
6/// observers for a single property by name or for all properties.
7pub trait PropertyObserverContainer {
8    /// Observes the property with the given name.
9    /// A handle will be automatically created and stored
10    fn observe_with_handle<F>(&self, name: &str, subscriber: F) -> u128
11    where
12        F: FnMut(&Value) + 'static + Send;
13
14    /// Propagates the value from the property with the given name to the target property with the given name.
15    fn propagate(&self, name: &str, target_property_name: &str);
16
17    /// Removes the observers of the property with the given name and the given observer handle.
18    fn remove_observer(&self, name: &str, handle_id: u128);
19
20    /// Removes all observers of the property with the given name that are managed by this PropertyObserverContainer.
21    fn remove_observers(&self, name: &str);
22
23    /// Removes all observers that are managed by this PropertyObserverContainer.
24    fn remove_all_observers(&self);
25}