The small choices people make in an app — the theme, the language, a menu pinned open — and whose they are.
| A choice is… | Declared with | Kept in | Signing out |
|---|---|---|---|
| the person's (theme, language, a welcome already seen) | preferences.OfThePerson("theme") |
the server, with a copy in the browser | erases the browser's copy |
| this device's (a menu pinned open on a wide screen) | preferences.OfThisDevice("menu-pinned") |
the browser only | keeps it |
var Theme = preferences.OfThePerson("theme")
value, ok := Theme.Get() // ok is false when nobody chose: the app's own default applies
err := Theme.Set("dark")
err = Theme.Forget()
var WelcomeSeen = preferences.OfThePerson("welcome-seen")
seen, _ := WelcomeSeen.For(m.ModelName()).Get() // one per screenNothing sensitive is a preference. Everything here is stored where any script of the page can read it (OWASP HTML5 Security Cheat Sheet). A secret never lives in the page: passkeys stay in the authenticator and the session in an HttpOnly cookie.
A component only imports webtyp.com/preferences, which uses nothing but the browser: it never knows about sessions or servers. The app shell plugs the server in.
webtyp.com/preferences/mineis the crud module that keeps each person's choices (key: person + name; every rule refuses another person's row).appkitbuilds it and grants it to every signed-in person in any app with a sign-in, andappkitcmigrates its table: the app lists nothing.- In the browser,
appkitcallspreferences.Fillwith the person's choices once they are known,preferences.SaveWith(mine.Saver(…))so their changes reach the server, andpreferences.ForgetPerson()when they sign out. preferences.Languageis the one choice two pieces share:components/languagepickerwrites it andappkitapplies it before drawing the page.- A page that reloads right after a change waits for the server:
preferences.WhenSaved(func() { dom.Navigate("") }).
Outside a browser nothing is kept: every preference reads as not chosen.
| File | What |
|---|---|
| docs/TESTS.md | Test suite inventory |