preferences/event-target

Unstable

Listen to changes to the Preferences system in Firefox. This enables add-ons to listen to change events to the system-wide settings. These are the same preferences that are exposed to users in the about:config page.

preferences/service gives you full access to the preferences system. You can also use the simple-prefs module to access just the preferences for your own add-on and expose them to the user in the Add-on Manager.

Globals

Constructor

PrefsTarget(options)

Parameters

options : object
Required options:

Name Type
branchName string

By default this is "", the root.

Example

var { PrefsTarget } = require("sdk/preferences/event-target");

// listen to the same branch which reqire("sdk/simple-prefs") does
var target = PrefsTarget({ branchName: "extensions." + require("sdk/self").preferencesBranch + "." });

target.once("test", function(prefName) {
  console.log(prefName) // logs "test"
  console.log(target.prefs[name]) // logs true
});

target.once("", function() {
  console.log(prefName) // logs "test"
  console.log(target.prefs[name]) // logs true
})

// changing a pref which our target listens to
require("sdk/simple-prefs").prefs.test = true;