<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to tell when all layers and sublayers are done loading in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-tell-when-all-layers-and-sublayers-are-done/m-p/1134892#M75977</link>
    <description>&lt;P&gt;I have a list of both the layers and map-image sublayers, that I want to keep updated.&amp;nbsp; It should update in the beginning, whenever all the initial layers/sublayers are done loading, as well as whenever a layer is added or removed from the map.&amp;nbsp; In any case, I need to wait until any new layers and sublayers are done loading, or the list is inaccurate.&lt;/P&gt;&lt;P&gt;This is what I was trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const layersWatch = mapView.map.allLayers.on('change', (event) =&amp;gt; {
  if(event.target) {
    setLayersUpdating(true);
    const allLayerWhens = event.target.map((layer) =&amp;gt; {
      return layer.when();
    });

    Promise.allSettled(allLayerWhens).then((loadedLayerResults) =&amp;gt; {
      // It gets here with the expected results...
      const allSublayerWhens = [];
      loadedLayerResults.forEach((result) =&amp;gt; {
        if (result.value?.allSublayers?.length) {
          result.value.allSublayers.forEach((sublayer) =&amp;gt; {
            allSublayerWhens.push(sublayer.when());
          });
        }
      });
     
      Promise.allSettled(allSublayerWhens).then(() =&amp;gt; {
        // ...but never gets here:
        setLayersUpdating(false);
      });
    });
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 07:32:24 GMT</pubDate>
    <dc:creator>DavidKlinger</dc:creator>
    <dc:date>2022-01-19T07:32:24Z</dc:date>
    <item>
      <title>How to tell when all layers and sublayers are done loading</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-tell-when-all-layers-and-sublayers-are-done/m-p/1134892#M75977</link>
      <description>&lt;P&gt;I have a list of both the layers and map-image sublayers, that I want to keep updated.&amp;nbsp; It should update in the beginning, whenever all the initial layers/sublayers are done loading, as well as whenever a layer is added or removed from the map.&amp;nbsp; In any case, I need to wait until any new layers and sublayers are done loading, or the list is inaccurate.&lt;/P&gt;&lt;P&gt;This is what I was trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const layersWatch = mapView.map.allLayers.on('change', (event) =&amp;gt; {
  if(event.target) {
    setLayersUpdating(true);
    const allLayerWhens = event.target.map((layer) =&amp;gt; {
      return layer.when();
    });

    Promise.allSettled(allLayerWhens).then((loadedLayerResults) =&amp;gt; {
      // It gets here with the expected results...
      const allSublayerWhens = [];
      loadedLayerResults.forEach((result) =&amp;gt; {
        if (result.value?.allSublayers?.length) {
          result.value.allSublayers.forEach((sublayer) =&amp;gt; {
            allSublayerWhens.push(sublayer.when());
          });
        }
      });
     
      Promise.allSettled(allSublayerWhens).then(() =&amp;gt; {
        // ...but never gets here:
        setLayersUpdating(false);
      });
    });
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 07:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-tell-when-all-layers-and-sublayers-are-done/m-p/1134892#M75977</guid>
      <dc:creator>DavidKlinger</dc:creator>
      <dc:date>2022-01-19T07:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell when all layers and sublayers are done loading</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-tell-when-all-layers-and-sublayers-are-done/m-p/1134955#M75984</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/when-featurelayer-done-drawing/m-p/548912#M51085" target="_blank"&gt;Solved: When featurelayer done drawing - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://odoe.net/blog/quick-tip-arcgis-api-4-js-stuff-ready/" target="_blank"&gt;Quick Tip: ArcGIS API 4 for JS - When stuff is ready? (odoe.net)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 15:01:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-tell-when-all-layers-and-sublayers-are-done/m-p/1134955#M75984</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-01-19T15:01:03Z</dc:date>
    </item>
  </channel>
</rss>

