Subj : Re: Making a "Singleton" Chrome Extension To : netscape.public.mozilla.jseng,netscape.public.mozilla.xpcom From : Brendan Eich Date : Tue Jul 20 2004 09:17 am Brendan Eich wrote: > Kyle wrote: > >> I'm writing a chrome extension that currently creates an instance of >> an object when an overlay is loaded. This currently means that a new >> instance is created for every window that contains the overlay. >> >> I would prefer to be able to create a single instance of the object >> when the Mozilla starts, and make reference to this instance when >> other windows are created. This also means that I would like to keep >> the instance alive after the overlay that created it has been >> destroyed. >> >> This should just be a simple Singleton model. Is there some type of >> registry I can use to store and retrieve a reference to this object >> each time the overlay loads, and does anyone have any examples of a >> similar implementation? Thanks you, > > > You want to write an XPCOM component in JS, and call it via XPConnect. > Many examples exist. See > http://lxr.mozilla.org/mozilla/source/xpcom/sample/nsSample.js, > http://lxr.mozilla.org/mozilla/source/toolkit/mozapps/update/src/nsBackgroundUpdateService.js, > http://lxr.mozilla.org/mozilla/source/toolkit/mozapps/extensions/src/nsExtensionManager.js.in, > and others > (http://lxr.mozilla.org/mozilla/search?string=createInstance%3A). So the better newsgroup, I think, is m.xpcom. Cross-posting with followup-to: set. /be .