(event, options = {})
| 204 | } |
| 205 | |
| 206 | trigger(event, options = {}) { |
| 207 | if (!event || typeof event !== 'string') { |
| 208 | throw new Error('Invalid event!'); |
| 209 | } |
| 210 | options.event = event; |
| 211 | if (!this._handlers.has(options.event)) { |
| 212 | throw new Error('Unknown event!'); |
| 213 | } |
| 214 | const handler = this._handlers.get(options.event); |
| 215 | handler.call(this, options); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Like emit but receiver can send response |