can-event-queue
can-event-queue
mixes in event binding and dispatching methods that
use can-queues. This adds legacy binding methods addEventListener
and removeEventListener
. This package should not be used for new packages.
Use
var eventQueue = require("can-event-queue");
var obj = eventQueue(obj);
obj.on("event", function(){
console.log("event fired!")
});
obj.dispatch("event");
Critically, event handlers can be registered to run in different queues.
var obj = eventQueue(obj);
obj.on("event", function mutateHandler(){
console.log("mutate")
}, "mutate");
obj.on("event", function(){
console.log("notify")
}, "notify");
obj.dispatch("event");