When doing development with Lightning, I've noticed that the order events are fired/handled are not deterministic (this makes perfect sense given the architecture of Lightning). Unfortunately, what I've now found is that if my computer is not running at optimal speeds (say I'm running a high usage application while accessing Salesforce) items that must be in order may not be. Take this example:
I want to have a spinner show when an action is being performed and then have it disappear when the action completes. In order to accomplish this, I listen for the aura:waiting event and show the spinner when it fires. I then listen for the aura:doneWaiting event to hide the spinner. This normally works great and makes things extremely simple because I have this logic in my outer most component so all actions within are handled in one place. Unfortunately, what has been happening when I have less resources for the browser is that the aura:doneWaiting events are handled after the aura:waiting events, causing a spinner to show that is never hidden.
Has anyone seen this occur? Is this expected behavior? Any thoughts on how to resolve this issue?