addEventListener
Register an event handler to be called when an event is dispatched.
obj.addEventListener(eventName, handler(event, ...) [,queueName] )
Add a event listener to an object. Handlers attached by .addEventListener
get
called back with the dispatch
event
object and any arguments used to dispatch. @can.onKeyValue bindings do
not get the event object.
var mixinMapBindings = require("can-event-queue/map/map");
var obj = mixinMapBindings({});
obj.addEventListener("foo", function(event){ ... });
Parameters
- eventName
{String}
:The name of the event to listen for.
- handler
{function(event, arg...)}
:The handler that will be executed to handle the event. The handler will be called with the dispatched
event
andargs
. - queueName
{String}
:The name of the can-queues queue the handler will called back within. Defaults to
"mutate"
.
Returns
{Object}
:
Returns the object .addEventListener
was called on.