Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XPCOM Singleton Question

10 views
Skip to first unread message

Alex Iskold

unread,
Nov 6, 2006, 8:44:44 PM11/6/06
to
Hi,

We have recognized a need to have a singleton component in our application,
which stores the data that can be shared between all Windows.

We have done research and see that we can create a singleton component in
XPCOM.
All we need to do is to store an object, so all of our code is going to
basically do this:

// This is pseudo code
getCreateObject() {
var comp = getSingletonComponent();
var obj = comp.getObject();
if ( obj == null ) {
obj = createObject();
comp.store( obj );
}
return obj;
}

In other words, we are trying to mimic classical flyweight pattern via
singleton XPCOM component.

My question is: is there a service or component that we can use already?
It seems like quote common problem, so I decided to ask.

In the code below the usage would be:

// This is pseudo code
getCreateObject() {
var comp = getSingletonService.createSingleton( "MyUniqueName" );
var obj = comp.getObject();
...
}

Thanks in advance for your help,

Alex


--
alex iskold
founder & cto
http://www.adaptiveblue.com

0 new messages