Aug 24 2012

Object.observe

Object.observe

This proposed API sounds fantastic. Property observing is a key component of data-binding, used in places like Ember, Shipyard, and Angular. Unfortunately, it requires using special get and set methods, and only on objects derived from the library; using a regular {} or [] doesn’t work.

Object.observe would make it simply part of JavaScript, likely be more performant than any of the libraries, and allow developers to use plain native objects. The proposed usage is this:

Object.observe(foo, function(changes) {
    changes.forEach(function(c) {
        // c === { name: 'bar', type: 'new', object: foo }
    });
});

There’s a video and repo for a working prototype of this stuff too.

  • #javascript
  • #programming
  • #mvc
  • #shipyard