(event, fn)
| 5 | export default class Emitter { |
| 6 | // Add an event listener for given event |
| 7 | on(event, fn) { |
| 8 | this._callbacks = this._callbacks || {}; |
| 9 | // Create namespace for this event |
| 10 | if (!this._callbacks[event]) { |
| 11 | this._callbacks[event] = []; |
| 12 | } |
| 13 | this._callbacks[event].push(fn); |
| 14 | return this; |
| 15 | } |
| 16 | |
| 17 | emit(event, ...args) { |
| 18 | this._callbacks = this._callbacks || {}; |