@can.onKeyValue
Register an event handler to be called when a key value changes.
canReflect.onKeyValue( obj, key, handler(newVal) [,queueName] )
Add a key change handler to an object. Handlers attached by .onKeyValue
get
called back with the new value of the key
. Handlers attached with [can-event-queue/map/map.can.addEventListener]
get the event object.
var mixinMapBindings = require("can-event-queue/map/map");
var obj = mixinMapBindings({});
canReflect.onKeyValue( obj, "prop", function(newPropValue){ ... });
Parameters
- key
{String}
:The name of property to listen to changes in values.
- handler
{function(newVal, oldValue)}
:The handler that will be called back with the new and old value of the key.
- queueName
{String}
:The name of the can-queues queue the handler will called back within. Defaults to
"mutate"
.