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 init_delayed<Data, T: Default + PartialEq, EF: Fn(&Data) -> T, NF: Fn(&Data, &T)>(
&self,
data: Data,
eval_fn: EF,
notify_fn: NF,
)
pub fn init_delayed<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.
Same as Self::init, but the first eval function is called in a future evaluation of the event loop.
This means that the change tracker will consider the value as default initialized, and the eval function will
be called the firs ttime if the initial value is not equal to the default constructed value.
Sourcepub fn run_change_handlers()
pub fn run_change_handlers()
Run all the change handler that were queued.