Trait wnf::StateListener

source ·
pub trait StateListener<T>
where T: ?Sized,
{ // Required method fn call(&mut self, accessor: DataAccessor<'_, T>); }
Available on crate feature subscribe only.
Expand description

A trait for types that are capable of listening to state updates

Note that there is a blanket implementation of this trait for all closure types F: FnMut(DataAccessor<'_, T>), so you usually don’t need to implement this trait for your own types. It is useful, however, if you need a state listener whose type you can name explicitly. Since closure types are anonymous, you can instead define your own type and implement StateListener<T> for it.

Required Methods§

source

fn call(&mut self, accessor: DataAccessor<'_, T>)

Calls this state listener

The provided DataAccessor<'_, T> can be used to obtain the state data at the time the update took place.

Implementors§

source§

impl<F, T> StateListener<T> for F
where F: FnMut(DataAccessor<'_, T>), T: ?Sized,