pub struct SaveableScope { /* private fields */ }Expand description
Where the rememberSaveable calls in some content keep their values: a
key namespace, and whether the values are saved in preferences or kept
only in memory. A navigation host gives each back-stack entry its own, so
two visits of one screen keep apart.
Implementations§
Source§impl SaveableScope
impl SaveableScope
Sourcepub fn current() -> Self
pub fn current() -> Self
The scope where this is composed: the one ProvideSaveableScope
gives, else the root scope, which saves each key as it is in
preferences. Call it while composing.
Sourcepub fn child(&self, name: impl Display) -> Self
pub fn child(&self, name: impl Display) -> Self
The scope named name inside this one. It saves where this one does.
Sourcepub fn in_memory(self) -> Self
pub fn in_memory(self) -> Self
This scope with its values kept only in memory, until the scope is forgotten or the process ends.
Sourcepub fn namespace(&self) -> Option<&str>
pub fn namespace(&self) -> Option<&str>
The prefix of the keys this scope saves under; None for the root
scope, whose keys stand as they are.
Sourcepub fn is_durable(&self) -> bool
pub fn is_durable(&self) -> bool
Whether this scope saves its values in preferences, rather than
keeping them in memory.
Sourcepub fn restore(&self, key: &str) -> Option<String>
pub fn restore(&self, key: &str) -> Option<String>
The value last saved under key in this scope.
Sourcepub fn register(
&self,
key: &str,
read: impl Fn() -> Option<String> + 'static,
) -> SaveableRegistration
pub fn register( &self, key: &str, read: impl Fn() -> Option<String> + 'static, ) -> SaveableRegistration
Saves what read returns under key in this scope at each save
boundary while the registration lives, and keeps its last value once
it is dropped, as rememberSaveable does. read must not perform
storage I/O.
Sourcepub fn forget(&self)
pub fn forget(&self)
Forgets everything saved in this scope: the state of a back-stack entry once it is popped. Saves in it stop, and stored values are removed at the next save boundary. The root scope forgets nothing.
Sourcepub fn forget_children_except<N: Display>(
&self,
keep: impl IntoIterator<Item = N>,
)
pub fn forget_children_except<N: Display>( &self, keep: impl IntoIterator<Item = N>, )
Forgets everything saved in this scope apart from the child scopes
named in keep, as SaveableScope::forget does.