zng::widget::node

Function widget_state_get_state

source
pub fn widget_state_get_state<T>(
    child: impl UiNode,
    get_new: impl Fn(StateMapRef<'_, WIDGET>, &T) -> Option<T> + Send + 'static,
    get_deinit: impl Fn(StateMapRef<'_, WIDGET>, &T) -> Option<T> + Send + 'static,
    state: impl IntoVar<T>,
) -> impl UiNode
where T: VarValue,
Expand description

Helper for declaring state getter properties that are controlled by values in the widget state map.

The get_new closure is called with the widget state and current state every init and update, if it returns some value the state updates. The get_deinit closure is called on deinit to get the reset value.