Object.observe(obj, callback) Object.getNotifier(object).notify({
object: obj,
type: "synthetic"
}); var square = new Square(0, 0, 10, 10); function simpleton() { // do simpleton stuff } Object.observe(square, simpleton); function smartypants() { // do smart stuff } Object.observe(square, smartypants,[‘new’, ‘updated’, ‘deleted’, 'embiggened'] );
embiggin: function(int amount) {
notifier.performChange('embiggened', () => {
this.width *= amount;
this.height *= amount;
});
notifier.notify({
type: 'embiggened',
amount: amount
});
} square.embiggen(2); {
object: square, type: 'updated',
name: 'width', oldValue: 10
},
{
object: square, type: 'updated',
name: 'height', oldValue: 10
} {
object: square, type: 'embiggened', amount: 2
} {
object: arr,
type: ‘splice’,
index: <number>,
removed: <array>,
addedCount: <number>
}
Array.observe = function(obj, callback) { return Object.observe(obj, callback, ['new', 'updated', 'deleted', 'splice']);}
{ object: map, type: 'set', key: k } { object: map, type: 'replace', key: k, oldValue: v } { object: map, type: 'deleted', key: k, oldValue: v }{ object: set, type: 'set', key: k }{ object: set, type: 'deleted', key: k } 




