I have a component with a private goog.net.XhrManager that it uses to make ajax requests to populate lists and tables with server data.
I also have a div that has a loading indicator and the CSS all set up to show and hide it.
Right now, I have the XhrManager executing a series of calls, and I use the event id passed into the XhrManager's send method to discern what to do in the COMPLETE callback. However, since the order of calls can potentially be arbitrary in the READY and [SUCCESS, ERROR] callbacks where I display and hide the loading indicator respectively, I'm having a hard time cleanly turning on and off the indicator.
I am wondering if there is another set of callbacks or a different technique I should use. How does g-mail do this for example when you click the next arrow to page through mail if it is not only loading the next page of mail, but contextual sidebar info, ads, etc?
You could use reference counting for each request that is pending to set/unset the indicator. Another option is to accumulate all the results using the goog.async.DeferredList.awaitDeferred(otherDeferred) so you make it synchronous. I'm using the last method to accomplish this. Hope this puts you in the right direction.
Regards,
Rene