can-event-queue/map/map
Mixin methods and symbols to make this object or prototype object behave like a key-value observable.
mixinMapBindings( obj )
Adds symbols and methods that make obj
or instances having obj
on their prototype
behave like key-value observables.
When mixinMapBindings
is called on an obj
like:
var mixinMapBindings = require("can-event-queue/map/map");
var observable = mixinValueBindings({});
observable.on("prop",function(ev, newVal, oldVal){
console.log(newVal);
});
observable[canSymbol.for("can.dispatch")]("prop",[2,1]);
// Logs: 2
mixinMapBindings
adds the following properties and symbols to the object:
addEventListener - Register an event handler to be called when an event is dispatched.
@can.getWhatIChange - Return observables whose values are affected by attached event handlers
@can.isBound - Return if the observable is bound to.
@can.offKeyValue - Unregister an event handler to be called when an event is dispatched.
@can.onKeyValue - Register an event handler to be called when a key value changes.
dispatch - Dispatch event and key binding handlers.
listenTo - Listen to an event and register the binding for simplified unbinding.
off - A shorthand method for unbinding an event.
on - A shorthand method for listening to event.
one - Register an event handler that gets called only once.
removeEventListener - Unregister an event handler to be called when an event is dispatched.
stopListening - Stops listening for registered event handlers.
Furthermore, mixinMapBindings
looks for the following symbols on the object's .constructor
property:
@can.dispatchInstanceBoundChange
- Called when the bind status of an instance changes.@can.dispatchInstanceOnPatches
- Called if dispatch is called withevent.patches
as an array of patches.