ChangeTracker

Struct ChangeTracker 

Source
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

Source

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

Source

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.

Source

pub fn clear(&self)

Clear the change tracker. No notify function will be called after this.

Source

pub fn run_change_handlers()

Run all the change handler that were queued.

Trait Implementations§

Source§

impl Debug for ChangeTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChangeTracker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for ChangeTracker

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.