standardize watch feature

Mike Samuel mikesamuel at gmail.com
Sun Dec 27 07:24:59 PST 2009


ES5 Setters let you do this.

Object.defineProperty(
    model, 'x',
    { 'set': function (newx) { model.x_ = x; },
      'get': function() { return model.x_ }, writable: true })

2009/12/27 memolus at googlemail.com <memolus at googlemail.com>:
> https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference:Global_Objects:Object:watch
>
> I really do need it for my Modell-View-Controller application. If
> didn't had it, I had to use
>
> modell.doSth();
> modell.x++;
> modell.save();
>
> where modell.save() will call the controller to reload all properties
> into view. With the watch feature I'm saving the last line. Property
> changings on the modell affects the view instantly.
>
> May you can introduce the feature as part of a new event concept.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list