* Helper to emit events via postMessage using a port. * @param {String} event The event descriptor * @param {Object} options (optional) Data to be sent in the event
(event, options = {})
| 195 | * @param {Object} options (optional) Data to be sent in the event |
| 196 | */ |
| 197 | emit(event, options = {}) { |
| 198 | if (!event || typeof event !== 'string') { |
| 199 | throw new Error('Invalid event!'); |
| 200 | } |
| 201 | this.#checkConnection(); |
| 202 | options.event = event; |
| 203 | this._port.postMessage(options); |
| 204 | } |
| 205 | |
| 206 | trigger(event, options = {}) { |
| 207 | if (!event || typeof event !== 'string') { |
no test coverage detected