This API is available on Firefox OS for internal applications 仅。
Sets up a callback function to be notified when a specific setting's value changes.
注意:
If you want to listen for and react to any change to any setting, you can directly set a callback function using the
onsettingchange
特性为
SettingsManager
对象。
SettingsManager.addObserver(settingName, callback);
settingName
callback
MozSettingsEvent
providing details about the change that occurred.
// Listen to changes on the wifi.enabled setting
navigator.mozSettings.addObserver('wifi.enabled', function (event) {
console.log('wifi.enabled: ' + event.settingValue);
});
Not part of any specification yet; however, this API will be discussed at W3C as part of the System Applications Working Group .