prefs by Trigger.io

Currently displaying version

prefs: Preferences

The forge.prefs namespace allows you to save state in your app. State is persisted between restarts and is consistent across different pages in your app.

API

forge.prefs.get(name, success, error)

iOS, Android, Web

If the preference has not been set (with forge.prefs.set), and there is no default value for this preference, null is returned.

Parameters:
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

forge.prefs.set(name, value, success, error)

iOS, Android, Web

The preference value given here will override a default value (if one was given).

Parameters:
name
string the name of the preference you want to save
name
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

forge.prefs.clear(name, success, error)

iOS, Android, Web

Un-sets the given preference name, so that future calls to forge.prefs.get will return undefined (or the default preference value, if given).

Parameters:
name
string the name of the preference you want 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

forge.prefs.clearAll(success, error)

iOS, Android, Web

Un-sets all preference names, so that calls to forge.prefs.get will return undefined (or the default value for a preference, if given).

Parameters:
success
function() callback to be invoked when no errors occurs
error
function(content) called with details of any error which may occur

forge.prefs.keys(success, error)

iOS, Android, Web

Find which preferences have been set.

Parameters:
success
function(keysArray) invoked with an array of the set key names as its only argument
error
function(content) called with details of any error which may occur