onKeysAdded
Register an event handler on a MapLike object, triggered on new keys being added.
onKeysAdded(obj, handler)
Register an event handler on the Map-like object obj
to trigger when a new key or keys are set on
obj
. obj
must implement @@can.onKeysAdded to be compatible with
can-reflect.onKeysAdded. The function passed as handler
will receive an Array of Strings as its one
argument.
var obj = new DefineMap({ foo: "bar" });
canReflect.onKeysAded(obj, function(newKeys) {
console.log(newKeys);
});
foo.set("baz", "quux"); // -> logs '["baz"]'
Parameters
- obj
{Object}
:an observable MapLike that can listen to changes in named properties.
- handler
{function(Array)}
:the callback function to receive the array of added keys