Firefox extension js object initialization
Posted
by Michael
on Stack Overflow
See other posts from Stack Overflow
or by Michael
Published on 2010-05-06T23:58:38Z
Indexed on
2010/05/07
4:58 UTC
Read the original article
Hit count: 232
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?
© Stack Overflow or respective owner