* Emits an event with the specified data to all currently registered listeners. * Callbacks will fire in the order in which they are registered (FIFO). This * function is not exposed publicly; it is used by QUnit internals to emit * logging events. * * @private * @method emit *
(eventName, data)
| 1261 | * @return {Void} |
| 1262 | */ |
| 1263 | function emit(eventName, data) { |
| 1264 | if (objectType(eventName) !== "string") { |
| 1265 | throw new TypeError("eventName must be a string when emitting an event"); |
| 1266 | } |
| 1267 | |
| 1268 | // Clone the callbacks in case one of them registers a new callback |
| 1269 | var originalCallbacks = LISTENERS[eventName]; |
| 1270 | var callbacks = originalCallbacks ? [].concat(toConsumableArray(originalCallbacks)) : []; |
| 1271 | |
| 1272 | for (var i = 0; i < callbacks.length; i++) { |
| 1273 | callbacks[i](data); |
| 1274 | } |
| 1275 | } |
| 1276 | |
| 1277 | /** |
| 1278 | * Registers a callback as a listener to the specified event. |
no test coverage detected