Function zng_wgt::node::widget_state_get_state

source ยท
pub fn widget_state_get_state<T: VarValue>(
    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
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.