prefs: Preferences¶
Preferences are used to save state in your extension. State is persisted between restarts and is consistent across all parts of your app.
API¶
get¶
- prefs.get(name, success, error)¶
Arguments: - name (string) -- the name of the preference you want to query
- success (function(value)) -- will be invoked as the preference value as its only parameter
- error (function(content)) -- called with details of any error which may occur
Platforms: All
If the preference has not been set (with set), and there is no default value for this preference, null is returned.
set¶
Platforms: All
- prefs.set(name, value, success, error)¶
Arguments: - name (string) -- the name of the preference you want to save
- value -- the value to save
- success (function()) -- callback to be invoked when no errors occurs
- error (function(content)) -- called with details of any error which may occur
The preference value given here will override a default value (if one was given).
clear¶
Platforms: All
- prefs.clear(name, success, error)¶
Arguments: - name (string) -- the name of the preference to un-set
- success (function()) -- a callback to be invoked (with no arguments) when the operation is complete
- error (function(content)) -- called with details of any error which may occur
Un-sets the given preference name, so that future calls to set will return undefined (or the default preference value, if given).
clearAll¶
Platforms: All
- prefs.clearAll(success, error)¶
Arguments: - success (function()) -- a callback to be invoked (with no arguments) when the operation is complete
- error (function(content)) -- called with details of any error which may occur
Un-sets all preference names, so that calls to set will return undefined (or the default value for a preference, if given).