It's documentation day at the Office, and I wanted to share a small codepen sample which I'm open to any code review! We have some large map services that can sometimes take a while to load, and it would be nice to provide a visual indicator to users that the map is loading (those little dots in the Layer List aren't cutting it). So, my sample is designed to watch each of the map.layerViews.updating properties, and to wait until all of the .updating properties are false to 'hide' a calcite-loader (and to show it again if any .updating turns true).
Codepen: whenAllLayerViewsReady
(draw your eyes to the top-right of the map as you zoom in and out of Manhattan...)
For some additional background, checkout this original video from 2017 that walks through the sequence of events from mapView to layerView. The sequence is mostly the same today, but the exact watchUtils from that demonstration are now deprecated. Quick Tip: ArcGIS API 4 for JS - When stuff is ready?
Even so, that video was relevant when another Community Question asked about watching multiple layers:
Solved: Re: When featurelayer done drawing - Esri Community
But that sample relied on hard-coding feature layers and arrays: I wanted a utility to work on any map with any number of layers (especially maps with lots of layers, as the usefulness of this bit of code increases with more layers and longer load times!)
Please do share if there's anything in the sample that could be tightened up!