module.exports = class Event extends require './base'
module.exports = class Event extends require './base'
Events are broadcasted down the hierarchy tree (from parents to children), in attempt to reach the event target and get dispatched to listeners.
On their travel path, the events are being captured and dispatched to the capturing listeners.
After the event has reached it’s target or there is nowhere to broadcast the event anymore, the event callback should be called.
There are three ways to control event propagation
When event does not propagate anymore, event callback will be called.
Creates Event instance.
Create Event instance.
constructor: (type, callback) ->
Create named arguments object.
args = (if typeof type is 'string' then type:type else type or {})
callback
argument overrides the args.callback
if typeof callback is 'function' then args.callback = callback
Call super
to initialize #___runtime and copy properties.
super args
If enabled, calculate the creation timestamp
if @timestamp is true
date = Date.now()
with high precision
perf = performance?.now() or 0
@timestamp = 1000 * date + Math.floor 1000 * (perf - Math.floor perf)
type
callback
this
and first argumentargs
args.target
args.timestamp
cancel: ->
@___runtime.cancel = true
return this
stop: ->
@___runtime.stop = true
return this
abort: ->
@aborted = true
return this