@modoki/engine / index / PreferencesBackend
Class: PreferencesBackend
Native backend (iOS/Android) via @capacitor/preferences — NSUserDefaults / SharedPreferences. Each single-key write is ATOMIC (no torn value): iOS rewrites the plist atomically; Android's SharedPreferences writes the whole file atomically.
Caveat (durability): on Android the plugin uses SharedPreferences.Editor.apply(), which returns BEFORE the write reaches disk — so an awaited set() / flush() guarantees atomicity but NOT that the byte is persisted. This is the best-effort durability the contract already documents; flush-on-background (Phase 3) must not assume an awaited set is on disk, and leans on the OS lifecycle to actually sync.
Implements
Constructors
Constructor
new PreferencesBackend():
PreferencesBackend
Returns
PreferencesBackend
Storage
getAll()
getAll(
prefix):Promise<Record<string,string>>
All entries whose full key starts with prefix, as { fullKey: envelopeString }.
Parameters
prefix
string
Returns
Promise<Record<string, string>>
Implementation of
remove()
remove(
fullKey):Promise<void>
Remove one entry.
Parameters
fullKey
string
Returns
Promise<void>
Implementation of
set()
set(
fullKey,value):Promise<void>
Write one entry atomically (full key → envelope string).
Parameters
fullKey
string
value
string
Returns
Promise<void>