Trigger.io

Trigger.io Forge Documentation

Important

This documentation is deprecated, and only kept here to support users of browser extension APIs. If you are using Trigger.io for iOS or Android, see https://trigger.io/docs/.

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.

Config

The prefs module must be enabled in config.json

{
    "modules": {
        "prefs": true
    }
}

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).

keys

Platforms: All

prefs.keys(success, error)
Arguments:
  • 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

Find which preferences have been set.