Methods
addListener(feature, callback)
Add a listener for feature state changes
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
string | Feature to listen for (or 'all' for all changes) |
callback |
function | Callback function (feature, enabled, oldEnabled) |
- Source:
disable(feature, persistopt)
Disable a feature
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
feature |
string | Feature flag key |
||
persist |
boolean |
<optional> |
true | Whether to save to localStorage |
- Source:
enable(feature, persistopt)
Enable a feature
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
feature |
string | Feature flag key |
||
persist |
boolean |
<optional> |
true | Whether to save to localStorage |
- Source:
getAllConfigs() → {Object}
Get all feature configurations
- Source:
Returns:
All feature configurations
- Type
- Object
getConfig(feature) → {Object|null}
Get feature configuration
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
string | Feature flag key |
- Source:
Returns:
Feature configuration or null if not found
- Type
- Object | null
getDebugInfo() → {Object}
Get debug information about feature flags
- Source:
Returns:
Debug information
- Type
- Object
getDefaultState() → {Object}
Get default feature state from configuration
- Source:
Returns:
Default feature state
- Type
- Object
getState() → {Object}
Get current state of all features
- Source:
Returns:
Current feature state
- Type
- Object
initializeFromUrl()
Initialize feature flags from URL parameters
- Source:
isEnabled(feature) → {boolean}
Check if a feature is enabled
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
string | Feature flag key |
- Source:
Returns:
Whether the feature is enabled
- Type
- boolean
loadFeatureState() → {Object}
Load feature state from localStorage with defaults
- Source:
Returns:
Current feature state
- Type
- Object
notifyListeners(changedFeatureopt)
Notify listeners of feature state changes
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
changedFeature |
string |
<optional> |
null | Specific feature that changed (optional) |
- Source:
removeListener(feature, callback)
Remove a listener for feature state changes
Parameters:
| Name | Type | Description |
|---|---|---|
feature |
string | Feature to stop listening for |
callback |
function | Callback function to remove |
- Source:
reset()
Reset all features to default state
- Source:
saveFeatureState()
Save current feature state to localStorage
- Source:
toggle(feature, persistopt) → {boolean}
Toggle a feature on/off
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
feature |
string | Feature flag key |
||
persist |
boolean |
<optional> |
true | Whether to save to localStorage |
- Source:
Returns:
New state after toggle
- Type
- boolean