* The new event handling style to asign a function to an event. * @param {String} event The event descriptor * @param {Function} handler The event handler
(event, handler)
| 183 | * @param {Function} handler The event handler |
| 184 | */ |
| 185 | on(event, handler) { |
| 186 | if (!event || typeof event !== 'string' || event === '_reply' || typeof handler !== 'function') { |
| 187 | throw new Error('Invalid event handler!'); |
| 188 | } |
| 189 | this._handlers.set(event, handler.bind(this._handlerObject || this)); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Helper to emit events via postMessage using a port. |
no test coverage detected