I'm kinda new to nodejs and I'm familiarizing myself with the event loop, queue, etc.
I was wondering what happens while I'm awaiting for a promise to resolve, regarding events. Will events be emitted while awaiting? (I'm subscribed to a message broker, getting a message triggers an event). Will the callbacks that are called on event be queued in the event queue?
I know that the callback won't be executed until the promise resolves but will the events be triggered?
Thanks ^^
When events are registered, their emission is simply controlled by whatever makes them emitted. However, the callback registered to handle the event would go first into the event queue, and their queue position is not determined by what other promises are awaiting resolution, rather the position is determined by whatever promises have been resolved or rejected and whatever events have been emitted ahead of the presently emitted event, and they will all wait for the call stack to be cleared before they are invoked in turn. The event loop is the process of doing that, that is, it executes tasks from the event queue only when the call stack is empty i.e. there is no ongoing task.