i_slint_core::properties

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 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 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.