storage
namespace storageFunctions
define(schema: SettingsSchema, name?: string): DefinedSettings
Binds a settings schema to a Bucket: reads apply defaults and writes are validated against the schema.
Plugins reach it through @unbound-app/settings, which the build generates from their settings.ts.
Returns
The settings, their hook and their reset.
Returns the Bucket with the given name. The name is the key the Bucket is saved under on disk.
Returns
The Bucket, with every operation bound to name.
onChange(predicate: SettingsPredicate, callback: (payload: SettingsPayload) => void): () => void
Registers a callback invoked on every settings change matching the predicate.
Returns
A function that removes the listener.
persist(): Promise<void>
Saves the settings changed since the last call. Each change already reached the loader when it was made.
Returns
A promise that resolves once the loader has saved them.
snapshot(options?: { includeSecrets?: boolean }): SettingsByBucket
Reads every Bucket at once. Most callers should read single keys, which stay in native code.
Returns
Every Bucket by name.
useBucket(name: string, predicate?: SettingsPredicate): Bucket
React hook that re-renders the component whenever a matching change occurs in the Bucket.
Returns
The Bucket, with every operation bound to name.
useSetting<T>(name: string, selector: (bucket: Bucket) => T, isEqual?: (previous: T, next: T) => boolean): T
React hook that selects from a Bucket, re-rendering only when the selection changes.
Returns
The selector's latest value.
Types
A Bucket: a named, persisted group of settings. Keys are dot-separated paths.
What storage.define returns: a schema's settings, bound to one Bucket.
Every Bucket's settings, keyed by Bucket name, as the loader persists them.
Payload describing a settings change, passed to onChange listeners and predicates.
Decides whether a settings change should reach a listener.
A plugin's settings as an object: reads apply defaults, writes are validated and saved. Sections are nested objects.
A plugin's settings schema, the JSON its settings.ts defineSettings(...) evaluates to at build time.