reactive_graph_reactive_model_api/
reactive_property_container.rs

1use serde_json::Value;
2
3use reactive_graph_graph::Mutability;
4use reactive_graph_graph::PropertyType;
5
6pub trait ReactivePropertyContainer {
7    /// Sends the current value down the stream if mutable.
8    fn tick_checked(&self);
9
10    /// Sends the current value down the stream.
11    fn tick(&self);
12
13    /// Returns true, if a property with the given name exists.
14    fn has_property(&self, name: &str) -> bool;
15
16    /// Adds a reactive property with the given name and the given initial value.
17    fn add_property<S: Into<String>>(&self, name: S, mutability: Mutability, value: Value);
18
19    /// Adds a reactive property with the given name and the given initial value.
20    fn add_property_by_type(&self, property: &PropertyType);
21
22    /// Removes the reactive property with the given name.
23    fn remove_property<S: Into<String>>(&self, name: S);
24
25    /// Observe the stream output flowing out of the stream of the property with the given
26    /// name. The handle_id allows to remove the observer again.
27    fn observe_with_handle<F>(&self, name: &str, subscriber: F, handle_id: u128)
28    where
29        F: FnMut(&Value) + 'static + Send;
30
31    /// Removes the subscriber with the given handle_id from the stream of the property with the
32    /// given name.
33    fn remove_observer(&self, name: &str, handle_id: u128);
34
35    /// Removes the subscribers of the property with the given name.
36    fn remove_observers(&self, name: &str);
37
38    /// Removes all subscribers of all properties.
39    fn remove_all_observers(&self);
40}