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