I am wondering if the emit
method of the EventEmitter
class operates synchronously or asynchronously.
For example, given that in both files eventEmitter
is the same instance of the EventEmitter
class:
// In file A
const myHandler = function() {
console.log("Handler executed.");
}
eventEmitter.on("eventA", myHandler);
// In file B
eventEmitter.emit("eventA");
console.log("Event emitted.");
Is the order of the log:
> "Handler executed."
> "Event emitted."
always guaranteed?