Dup Ver Goto 📝

examples

PT2/lang/js/observe-proxy does not exist
To
22 lines, 69 words, 510 chars Page 'examples' does not exist.

From NVRM's answer to this stackoverflow question

/* Simplest Object Observer */
Object.observe = (o, f) => new Proxy(o, { set: (a, b, c) => f(a, b, c) })

var obj = {
  foo: 0,
  bar: 1
};

// Assignment after creation, keep the variable name, extend.
obj = Object.observe(obj, function(target, prop, changes) {
  console.log("Change detected!", prop, changes)
})

obj.baz = 2;

obj.foo = 'hello';

/// EXAMPLES