I am working on an add-on as a project for Firefox and cannot get the hang of the onChange aspect of the ‘simple-prefs’ mod.
At the moment my add-on has to be disabled and then enabled again in order to activate any changes.
My code:
function onPrefChange(prefName) {
console.log("The preference " +
prefName +
" value has changed!");
}
require("sdk/simple-prefs").on("dismixed", onPrefChange);
require("sdk/simple-prefs").on("dissecure", onPrefChange);
require("sdk/simple-prefs").on("disapp", onPrefChange);
// listens to all changes
require("sdk/simple-prefs").on("", onPrefChange);
// Check prefs
var preferences = require("sdk/simple-prefs").prefs;
// check prefs
if (preferences.dismixed == true && preferences.disapp !== true)
{
dismixedtrue();
} else if (preferences.dissecure == true && preferences.disapp !== true) {
dissecure();
} else if (preferences.disapp == true) {
disapp();
} else {
disnormal();
}
The conditional statements in my code call different functions depending on the simple-pref settings.
How can my addon activate these changes without having to be disabled and then enabled?