Firefox Extender: respect preferences, avoid multiple notifications
Let's say my Firefox extension has several preferences, but some of them are grouped, like check interval, retry interval, destination url. They are only used in one function.
When I subscribe to the preference service and add an observer, a callback will be called observe
for each changed preference, so if by any chance a user changes all the settings in the group then I have to follow the same procedure for the same subsystem how many times I have items in this preference group. This is great redundancy!
I want to be observe
called only once for a preference group. Let's say
extensions.myextension.interval1
extensions.myextension.site
extensions.myextension.retry
so if one or all of these settings are changed, I only get one notification about it. In other words, no matter how many settings were changed in a branch, I want the callback to be observe
called once.
a source to share
When you register a pref watcher on a branch (in your case extensions.myextension), it will notify you of every preference change. There is no way to make it tell you just once about a change on a branch. When you call the watch method, you get the preference name that changes (this is the third parameter). You will have to filter your callbacks based on this.
a source to share