How to use Object.observe on Map? This doesn't work:
var map = new Map();
Object.observe(map, function() { console.log("ok"); });
map.set('key', 'value');
And this too:
var map = new Map();
Array.observe(map, function() { console.log("ok"); });
map.set('key', 'value');
The
Object.observe()facility is a general way to watch for changes to an object. Calls to theMapAPI do not trigger any of the events that the.observe()facility watches for, because no properties of theMapobject are added, remove, changed, etc.Current ES6/ES2015 specs make no provisions for observing updates to
MaporSetinstances, as far as I can tell.