|
From: Ugo on 7 May 2008 04:42 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 7 May 2008 08:39 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 7 May 2008 11:06 > Do you know a better way of this one: Yes change this: return new function( ) to this: return function( ) ;-)
From: RoLo on 7 May 2008 11:08 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 7 May 2008 12:14 >>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
|
Pages: 1 Prev: comp.lang.javascript FAQ - META 2008-05-07 Next: Could you tell me why ? |