@Sean: mmm, interesting!
On 2 Nov, 17:59, Sean McArthur <[email protected]> wrote: > I was going to recommend the approach you just mentioned, OR... Not really > using a class at all. > > When having Singletons, I tend to just create an object literal. If you want > the singleton to be able to fire events, just extend Events. > > var Moobox = { > > }; > > Object.extend(Moobox, new Events); > > On Tue, Nov 2, 2010 at 8:56 AM, stratboy <[email protected]> wrote: > > Hi thank you all @Ryan and Arieh. > > > > Singletons > > > > There's Christoph's Class.Singleton, I've never used it though: > > > >http://github.com/cpojer/mootools-class-extras > > > If you think that I should use a singleton, then I'm going to use some > > natural js methods that are described here: > > >http://keetology.com/blog/2009/07/23/up-the-moo-herd-iii-its-classy-n... > > > In particular, I really like this one, using a closure: > > > (function(){ > > > // variable for holding the instance.. > > var instance = null; > > > this.Singleton = new Class({ > > > initialize: function(name){ > > if (instance) return instance; > > instance = this; > > } > > }); > > })(); > > > Bye! :)
