Trait WidgetObserver

Source
pub trait WidgetObserver<T, W> {
    // Required methods
    fn set_action<Listen: Clone + 'static + Fn(&mut T, &Self)>(
        &mut self,
        l: Listen,
    );
    fn set_view<Update: Clone + 'static + Fn(&T, &mut Self)>(
        &mut self,
        u: Update,
    );
}
Expand description

A trait to bind actions and views to widgets in response to shared state.

Required Methods§

Source

fn set_action<Listen: Clone + 'static + Fn(&mut T, &Self)>(&mut self, l: Listen)

Sets the action to be executed when the widget is interacted with. The function receives mutable access to the shared state and a reference to the widget.

Source

fn set_view<Update: Clone + 'static + Fn(&T, &mut Self)>(&mut self, u: Update)

Binds a view function that updates the widget whenever the state changes. This is automatically triggered on STATE_CHANGED.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Send + Sync + 'static, W: WidgetExt + WidgetBase + 'static + Clone> WidgetObserver<T, W> for W