1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,557
    Vote Rating
    348
    LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of

      0  

    Default Ext.draw - SvgExporter question

    Ext.draw - SvgExporter question


    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:

    Code:
    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...

  2. #2
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,864
    Vote Rating
    933
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,557
    Vote Rating
    348
    LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of LesJ has much to be proud of

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    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

Thread Participants: 1