Skip to main content

rememberSaveable

Function rememberSaveable 

Source
pub fn rememberSaveable<T>(
    key: &'static str,
    saver: Saver<T>,
    initial: impl FnOnce() -> T,
) -> MutableState<T>
where T: Clone + 'static,
Expand description

State restored from preferences on first composition and saved at a flush.

Native hosts flush when leaving the foreground. Call crate::run_durable_saves on the composition thread for an explicit durability boundary. Mutations before that boundary are captured without another frame; abrupt termination before a successful flush can lose them. Failed flushes can be retried.