Re: Newbie: Object Instantiation
Doug Turner <[email protected]> Mon, 14 Oct 2002 12:49:20 -0700
| Newsgroups | gmane.comp.mozilla.devel.xpcom |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
timmy wrote: > Hello folks, > > Is it true, that objects of classes used in the XPCom- environment are > always created when a JS-function is called? Or is there the > possibility to have a singleton-instance of some specific classes, > that are instantiated on startup? How do I manage this? I need a > 'listener' on the application-side, that recognizes events on the GUI > (XUL). This listener should be a singleton. > > Thanx for your support, > Timmy no, many objects are created without a JS-function being involved. Your object's factory can ensure that the object is a singleton. To have your object be created at startup, you can add object as a category similar to this: http://lxr.mozilla.org/seamonkey/source/mailnews/mapi/mapihook/src/msgMapiSupport.cpp#91 Although, I am not sure that this approach is sure to work in the future. Doug Turner [email protected]