Firefox extension js object initialization
- by Michael
Note: this is about Firefox extension, not a js general question.
In Firefox extension project I need my javascript object to be initialized just once per Firefox window. Otherwise each time I open my window a new timers will be engaged, new properties will be used, so everything will start from scratch.
hope example below will demystify my question :)
var StupidExtension
{
statusBarValue: "Not Initialized Yet",
startup: function ()
{
...
// Show statusBarValue in Status Bar Panel
},
initTimerToRetrieveStatusBarValueFromNetwork: function ()
{
...
}
}
so each time you hit Ctrl+N a new window you will see "Not Initialized Yet" and then new timer will be fired, so after some time it retrieve data from network you will see value also on second window and so on. Ideally would be to have just a single timer function running and updating all status bar panels in all Firefox windows.
Of course I can do some caching, like saving the value in prefs or some other storage, then show it from there. But I feel like this is artificial.
So the question will be is there "native" technique of making static some parts of the object among all Firefox window instances?