rememberSecureValue
Two-way binding between a Compose MutableState and a single SecureVault key.
Reads come from SecureVault.observe — the state stays in sync with writes from any code path. Writes assigned through the returned state propagate back to the vault on a background dispatcher. The vault itself comes from LocalSecureVault, so callers do not need to plumb it manually.
@Composable
fun LoginScreen() {
var token by rememberSecureValue("auth.token", default = "")
OutlinedTextField(value = token, onValueChange = { token = it })
}Error policy: failures inside SecureVault.put / SecureVault.observe are swallowed silently to keep the UI from crashing during normal use; the last known good value is retained. Callers that need to surface errors should use SecureVault.observe and SecureVault.put directly.
Return
a MutableState whose reads are reactive and whose writes persist.
Since
0.3.0
Parameters
non-blank key inside the current vault's namespace.
the value to expose until the first emission arrives (and to fall back to whenever the stored value is null).
Overload that accepts an explicit vault instead of resolving it from LocalSecureVault. Useful for tests and for screens that bridge multiple namespaces.
Since
0.3.0