pub struct PropertyTracker<DirtyHandler = ()> { /* private fields */ }
Expand description
This structure allow to run a closure that queries properties, and can report if any property we accessed have become dirty
Implementations§
Source§impl<DirtyHandler: PropertyDirtyHandler> PropertyTracker<DirtyHandler>
impl<DirtyHandler: PropertyDirtyHandler> PropertyTracker<DirtyHandler>
Sourcepub fn register_as_dependency_to_current_binding(self: Pin<&Self>)
pub fn register_as_dependency_to_current_binding(self: Pin<&Self>)
Register this property tracker as a dependency to the current binding/property tracker being evaluated
Sourcepub fn is_dirty(&self) -> bool
pub fn is_dirty(&self) -> bool
Any of the properties accessed during the last evaluation of the closure called from the last call to evaluate is potentially dirty.
Sourcepub fn evaluate<R>(self: Pin<&Self>, f: impl FnOnce() -> R) -> R
pub fn evaluate<R>(self: Pin<&Self>, f: impl FnOnce() -> R) -> R
Evaluate the function, and record dependencies of properties accessed within this function. If this is called during the evaluation of another property binding or property tracker, then any changes to accessed properties will also mark the other binding/tracker dirty.
Sourcepub fn evaluate_as_dependency_root<R>(
self: Pin<&Self>,
f: impl FnOnce() -> R,
) -> R
pub fn evaluate_as_dependency_root<R>( self: Pin<&Self>, f: impl FnOnce() -> R, ) -> R
Evaluate the function, and record dependencies of properties accessed within this function. If this is called during the evaluation of another property binding or property tracker, then any changes to accessed properties will not propagate to the other tracker.
Sourcepub fn evaluate_if_dirty<R>(
self: Pin<&Self>,
f: impl FnOnce() -> R,
) -> Option<R>
pub fn evaluate_if_dirty<R>( self: Pin<&Self>, f: impl FnOnce() -> R, ) -> Option<R>
Call Self::evaluate
if and only if it is dirty.
But register a dependency in any case.
Sourcepub fn new_with_dirty_handler(handler: DirtyHandler) -> Self
pub fn new_with_dirty_handler(handler: DirtyHandler) -> Self
Sets the specified callback handler function, which will be called if any properties that this tracker depends on becomes dirty.
The handler
PropertyDirtyHandler
is a trait which is implemented for
any Fn()
closure
Note that the handler will be invoked immediately when a property is modified or marked as dirty. In particular, the involved property are still in a locked state and should not be accessed while the handler is run. This function can be useful to mark some work to be done later.