document state.rs #13

This commit is contained in:
2025-08-01 20:26:21 -05:00
parent 1debb6a576
commit a30afdeb28
+8 -5
View File
@@ -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<T> {
inner: Arc<Mutex<Inner<T>>>,
@@ -90,8 +98,3 @@ impl<T> DerefMut for Inner<T> {
&mut self.value
}
}
pub trait DependencyHandler: std::fmt::Debug + Send + Sync {
fn add(&self);
fn check(&self) -> bool;
}