Skip to main content

reactive_graph/graph/
node.rs

1/// A node in the reactive graph.
2pub trait ReactiveNode {
3    /// Notifies the source's dependencies that it has changed.
4    fn mark_dirty(&self);
5
6    /// Notifies the source's dependencies that it may have changed.
7    fn mark_check(&self);
8
9    /// Marks that all subscribers need to be checked.
10    fn mark_subscribers_check(&self);
11
12    /// Regenerates the value for this node, if needed, and returns whether
13    /// it has actually changed or not.
14    fn update_if_necessary(&self) -> bool;
15}
16
17/// The current state of a reactive node.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
19pub enum ReactiveNodeState {
20    /// The node is known to be clean: i.e., either none of its sources have changed, or its
21    /// sources have changed but its value is unchanged and its dependencies do not need to change.
22    Clean,
23    /// The node may have changed, but it is not yet known whether it has actually changed.
24    Check,
25    /// The node's value has definitely changed, and subscribers will need to update.
26    Dirty,
27}