save_state_node

Function save_state_node 

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

Helper node for implementing widget state saving.

The on_load_restore closure is called when either config status idle or window is loaded. If the window is already loaded and config idle the closure is called on init. 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.