pub struct ChangeTracker { /* private fields */ }
Expand description
A change tracker is used to run a callback when a property value changes.
The Change Tracker must be initialized with the Self::init
method.
When the property changes, the ChangeTracker is added to a thread local list, and the notify
callback is called when the Self::run_change_handlers()
method is called
Implementations§
Source§impl ChangeTracker
impl ChangeTracker
Sourcepub fn init<Data, T: Default + PartialEq, EF: Fn(&Data) -> T, NF: Fn(&Data, &T)>(
&self,
data: Data,
eval_fn: EF,
notify_fn: NF,
)
pub fn init<Data, T: Default + PartialEq, EF: Fn(&Data) -> T, NF: Fn(&Data, &T)>( &self, data: Data, eval_fn: EF, notify_fn: NF, )
Initialize the change tracker with the given data and callbacks.
The data
is any struct that is going to be passed to the functor.
The eval_fn
is a function that queries and return the property.
And the notify_fn
is the callback run if the property is changed
Sourcepub fn run_change_handlers()
pub fn run_change_handlers()
Run all the change handler that were queued.
Trait Implementations§
Source§impl Default for ChangeTracker
impl Default for ChangeTracker
Auto Trait Implementations§
impl !Freeze for ChangeTracker
impl !RefUnwindSafe for ChangeTracker
impl !Send for ChangeTracker
impl !Sync for ChangeTracker
impl Unpin for ChangeTracker
impl !UnwindSafe for ChangeTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more