Function zng_wgt_window::save_state_node

source ยท
pub fn save_state_node<S: ConfigValue>(
    child: impl UiNode,
    enabled: impl IntoValue<SaveState>,
    on_load_restore: impl FnMut(Option<S>) + Send + 'static,
    on_update_save: impl FnMut(bool) -> Option<S> + Send + 'static,
) -> impl UiNode
Expand description

Helper node for implementing widgets save.

The on_load_restore closure is called on window load or on init if the window is already loaded. The argument is the saved state from a previous instance.

The on_update_save closure is called every update after the window loads, if it returns a value the config is updated. If the argument is true the closure must return a value, this value is used as the CONFIG fallback value that is required by some config backends even when the config is already present.