I've been working on a solution to deal with map/feature services not loading on a map. Sometimes ArcGIS for Server has hiccups. I also wanted to have a loading screen disappear after the layers load. I have a CodePen demo with my solution. I'm looking for feedback (positive and negative).
I added a property, isLoaded, that stores a boolean for whether they layer has been loaded or not. It is initially false, and during the "load" event, is changed to true. It is set to false during the "requesterror" event.
I then have an interval timer that checks whether the isLoaded property for all layers is true. If it is, then the loading screen is removed.
During the "requesterror" event, I add some html to a hidden element (modal) that stores an error message. This element is then displayed. Upon closing the modal, the loading screen is removed.