diff --git a/src/state.rs b/src/state.rs index e44eadd..b3b9ec0 100644 --- a/src/state.rs +++ b/src/state.rs @@ -4,6 +4,14 @@ use std::{ sync::{Arc, Mutex, MutexGuard}, }; +/// Trait for tracking dependencies and reactivity. +pub trait DependencyHandler: std::fmt::Debug + Send + Sync { + /// Called when a dependent is registered. + fn add(&self); + /// Returns `true` if the state has changed since the last check. + fn check(&self) -> bool; +} + #[derive(Debug, Clone)] pub struct State { inner: Arc>>, @@ -90,8 +98,3 @@ impl DerefMut for Inner { &mut self.value } } - -pub trait DependencyHandler: std::fmt::Debug + Send + Sync { - fn add(&self); - fn check(&self) -> bool; -}