Firefox extension dev: observing preferences, avoid multiple notifications

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-10T06:04:34Z Indexed on 2010/05/10 6:14 UTC
Read the original article Hit count: 297

Filed under:
|
|

Let's say my Firefox extension has multiple preferences, but some of them are grouped, like check interval, fail retry interval, destination url. Those are used in just single function.

When I subscribe to preference service and add observer, the observe callback will be called for each changed preference, so if by chance user changed all of the settings in group, then I will have to do the same routine for the same subsystem as many times as I have items in that preferences group. It's a great redundancy!

What I want is observe to be called just once for group of preferences. Say

extensions.myextension.interval1
extensions.myextension.site
extensions.myextension.retry

so if one or all of those preferences are changed, I receive only 1 notification about it. In other words, no matter how many preferences changed in branch, I want the observe callback to called once.

© Stack Overflow or respective owner

Related posts about firefox

Related posts about extension