Expand description
Persistent settings (docs/prefs.md): a small key/value string store backed by each platform’s
native facility — NSUserDefaults on Apple, SharedPreferences on Android, a file store
elsewhere. day::prefs::{get, set, remove, contains}, plus bind to persist a Signal and
install_nav_store to make .restore(key) navigation survive a relaunch
(docs/navigation.md).
Promoted into the facade rather than left a satellite because it is what nearly every app
reaches for first, and because it is the one part that lives in the reactive layer. It stays
its own crate (day-part-prefs), so existing day_part_prefs::… paths keep working; this is
the same API under a shorter name. Opt out with default-features = false.
Functions§
- bind
- Two-way-bind a signal to a stored preference: seed the signal from the store now (when a
stored value exists and parses as
T), then persist every later change. Call it right after creating the signal, before anything reads it. The write-back lives in the current reactive scope, so it stops with the page that created the signal. - contains
- Whether a value is currently stored under
key. - get
- Read the string stored under
key, orNoneif it is absent (or no store is available on the platform). A stored empty string isSome(""), distinct from an absent key. - install_
nav_ store - Install this prefs store as the app’s navigation-persistence store (docs/navigation.md), so a
selectororstackmarked.restore(key)remembers its state across launches (and across an Android process death, since the store is disk-backed). Call once at startup, before the UI mounts. Nav keys are namespaced under aday.nav.prefix, so.restore("mail")never collides with the app’s ownset/getkeys. - remove
- Delete the value stored under
key. Returnstrueif a value existed and was removed,falseif the key was already absent (or the delete could not be committed). - set
- Persist
valueunderkey, overwriting any previous value. Returnstruewhen the write was committed. On Apple platforms this always succeeds; on Android it reflectsSharedPreferences.Editor.commit(); on the file-backed platforms it reflects whether the store file could be written (a missing config directory or a read-only home yieldsfalse).