Store API
Imperative API for managing flags programmatically.
The vibeFlagsStore provides a JavaScript API for managing flags without HTML elements. Useful for programmatic control, app initialization, or framework integrations.
Methods
register(config)
Register a single flag. Reads any existing value from localStorage, falling back to the default. This is called automatically by the HTML elements — use it when you need to register flags from JavaScript.
unregister(key)
Remove a flag from the store.
get(key)
Get the current value of a flag. Returns undefined if the flag isn't registered.
set(key, value)
Set a flag value. Validates against the flag's type and options. Persists to localStorage and dispatches a change event. Invalid values are silently ignored.
getAll()
Get all current flag values as a plain object.
getConfig()
Get all registered flag configurations as an array.
getConfigForKey(key)
Get the configuration for a specific flag. Returns undefined if not registered.
reset()
Reset all flags to their default values and clear localStorage.
Events
vibe-flags-changed
Dispatched on window whenever a flag value changes. Listen for it to react to flag changes from any source (toolbar, URL overrides, programmatic).
| Property | Type | Description |
|---|---|---|
detail.key | string | undefined | The flag that changed. undefined for bulk changes (reset). |
detail.state | VibeFlagsState | Snapshot of all current flag values. |