From: Ugo on
Hi guys,

how do you make a singleton access class?

Do you know a better way of this one:

var singletonClass = (function( )
{
// Private variable
var instance = null;

// Private Constructor
function myClass( )
{
//...
}

return new function( )
{
this.constructor = null;

this.getInstance = function( )
{
if( ! instance )
{
instance = new myClass( );
instance.constructor = null;
}

return instance;
}
}
})( );
From: Sam -- on
On Wed, 7 May 2008 10:42:51 +0200, Ugo <privacy(a)nospam.it> wrote:

>Hi guys,
>
>how do you make a singleton access class?
>
>Do you know a better way of this one:
>
>var singletonClass = (function( )
>{
> // Private variable
> var instance = null;
>
> // Private Constructor
> function myClass( )
> {
> //...
> }
>
> return new function( )
> {
> this.constructor = null;
>
> this.getInstance = function( )
> {
> if( ! instance )
> {
> instance = new myClass( );
> instance.constructor = null;
> }
>
> return instance;
> }
> }
>})( );
Pure qui? :-))
se ti vede ZERO...


ciao
From: RoLo on
> Do you know a better way of this one:
Yes

change this:
   return new function( )

to this:
return function( )

;-)
From: RoLo on
On May 7, 11:06 am, RoLo <roloswo...(a)gmail.com> wrote:
> > Do you know a better way of this one:
>
> Yes
>
> change this:
>     return new function( )
>
> to this:
>     return function( )
>
> ;-)

ok... sorry, I over read you code.. you can ignore my previous comment.
From: Ugo on
>>Hi guys,
>>how do you make a singleton access class?
>>Do you know a better way of this one:
[cut]
> Pure qui? :-))

ehh, gi� :)
Mi � tornato questo cruccio, e non so' fare n� trovare di meglio...
per tanto o provato a vedere cosa ne pensano qui...

> se ti vede ZERO...

ssshhh, zitto, non dire niente che forse non se ne accorge
:P

> ciao

Bye