Reputation: 9357
Can someone tell me if Object.observe()
will (once implemented) allow to register multiple observers via multiple calls? Or only the last one will stay?
For example if I do:
Object.observe(obj, myFirstFunction);
Object.observe(obj, mySecondFunction);
Will both functions get called when my object is updated or only mySecondFunction
?
Upvotes: 0
Views: 546
Reputation: 25882
I tried this and I got that both are being called.
var obj = {name:'MD'};
var myFirstFunction = function (changes) {
console.log("First " ,Object.keys(changes[0]))
}
var mySecondFunction = function (changes) {
console.log("Second ",Object.keys(changes[0]))
}
Object.observe(obj, myFirstFunction);
Object.observe(obj, mySecondFunction);
obj.name = "Mritunjay"
Upvotes: 1