PDA

View Full Version : Ext.draw - SvgExporter question



LesJ
6 Feb 2012, 8:58 AM
I thought I had a pretty good understanding how singletons are implemented in Ext... but the drawing package has some advanced uses...

.. take a look at the Ext.draw.engine.SvgExporter singleton... you will seen that all code is static, yet this is a singleton... and here's how it's used:


var svgString = Ext.draw.engine.SvgExporter.self.generate({}, surface);

Why this design? Why SvgExporter is a singleton since all code is class code?

I find the self usage very interesting...

mitchellsimoens
6 Feb 2012, 11:51 AM
Not the way I would have done it.... put it in the statics and within a closure, just seems unneeded to me but I'm not the author so maybe this convention was forced.

LesJ
6 Feb 2012, 11:59 AM
Not the way I would have done it.... put it in the statics and within a closure, just seems unneeded to me but I'm not the author so maybe this convention was forced.

The singleton part is interesting... w/o the singleton there would be no need to refer to self, which makes me wonder why singleton was used... This is probably the most interesting Ext code I have seen B)