onKeys
Register an event handler on a MapLike object, triggered on the key set changing
onKeys(obj, handler)
Register an event handler on the Map-like object obj
to trigger when obj
's keyset changes.
obj
must implement @@can.onKeys to be compatible with
can-reflect.onKeys. The function passed as handler
will receive an Array of object diffs (see
diffObject for the format) as its one argument.
var obj = new DefineMap({ foo: "bar" });
canReflect.onKeys(obj, function(diffs) {
console.log(diffs);
});
obj.set("baz", "quux"); // -> logs '[{"property": "baz", "type": "add", "value": "quux"}]'
Parameters
- obj
{Object}
:an observable MapLike that can listen to changes in named properties.
- handler
{function(Array)}
:the callback function to receive the diffs in the key set