* Activate (execute) all registered callback functions for the given * type, passing the given data, if any. * @param {string} type * @param {object} [data] * @returns { Events } this (the instance upon which the method was called)
(type, data)
| 94 | * @returns { Events } this (the instance upon which the method was called) |
| 95 | */ |
| 96 | fire(type, data) { |
| 97 | if (!this.hasEventListeners(type)) { |
| 98 | return this; |
| 99 | } |
| 100 | |
| 101 | var event = mergeData({ |
| 102 | type: type, |
| 103 | target: this |
| 104 | }, data); |
| 105 | |
| 106 | var listeners = this._tl_events[type].slice(); |
| 107 | |
| 108 | for (var i = 0, len = listeners.length; i < len; i++) { |
| 109 | if (listeners[i].action) { |
| 110 | listeners[i].action.call(listeners[i].context || this, event); |
| 111 | } else { |
| 112 | trace(`no action defined for ${type} listener`) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return this; |
| 117 | } |
| 118 | |
| 119 | }; |
no test coverage detected