document state.rs #13
This commit is contained in:
+8
-5
@@ -4,6 +4,14 @@ use std::{
|
|||||||
sync::{Arc, Mutex, MutexGuard},
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct State<T> {
|
pub struct State<T> {
|
||||||
inner: Arc<Mutex<Inner<T>>>,
|
inner: Arc<Mutex<Inner<T>>>,
|
||||||
@@ -90,8 +98,3 @@ impl<T> DerefMut for Inner<T> {
|
|||||||
&mut self.value
|
&mut self.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DependencyHandler: std::fmt::Debug + Send + Sync {
|
|
||||||
fn add(&self);
|
|
||||||
fn check(&self) -> bool;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user