observe
Returns a cold Flow that emits the current value of key and then re-emits whenever that key is written, removed, or the vault is cleared.
Semantics:
The first emission is the value present at collection start (or
null).Subsequent emissions are de-duplicated against the previously emitted value — collectors only see real changes.
The flow never completes on its own; cancel the collecting coroutine to unregister the underlying listener.
Platform notes:
Android — backed by
SharedPreferences.OnSharedPreferenceChangeListener; sees writes from any code holding the same prefs file.iOS — backed by an in-process broker. Writes performed from another process, or via raw
SecItem*calls outside this library, are not observed.
Throws VaultException.InvalidKey at collection time if key is blank.
Since
0.3.0