<?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 ensure multiple LayerViews are ready in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-ensure-multiple-layerviews-are-ready/m-p/1036447#M72049</link>
    <description>&lt;P&gt;Hi,&amp;nbsp; I'm new to the JavaScript API and am trying to use client side layerviews.&amp;nbsp; If I am working with multiple feature layers and want to make sure all of them are ready to use, is there an alternative to this nested ugliness?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        view.whenLayerView(myFirstLayer).then(function (myFirstLayerView) {
          view.whenLayerView(mySecondLayer).then(function (mySecondLayerView) {
            view.whenLayerView(myThirdLayer).then(function (myThirdLayerView) {
              // now that I know all my layer views are ready I can do things with them
            })
          })
        })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did see the following and was thinking it would be clearer to just to do this 3 times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var layerView = await view.whenLayerView(layer);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but got an error message that said "await is only valid in async functions and the top level bodies of modules".&amp;nbsp; I saw the following&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;at the top but don't really understand when I have to use it since most samples don't use it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;require([...], function (...) {

(async () =&amp;gt; {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 03:26:13 GMT</pubDate>
    <dc:creator>GaryB</dc:creator>
    <dc:date>2021-03-15T03:26:13Z</dc:date>
    <item>
      <title>How to ensure multiple LayerViews are ready</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-ensure-multiple-layerviews-are-ready/m-p/1036447#M72049</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I'm new to the JavaScript API and am trying to use client side layerviews.&amp;nbsp; If I am working with multiple feature layers and want to make sure all of them are ready to use, is there an alternative to this nested ugliness?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        view.whenLayerView(myFirstLayer).then(function (myFirstLayerView) {
          view.whenLayerView(mySecondLayer).then(function (mySecondLayerView) {
            view.whenLayerView(myThirdLayer).then(function (myThirdLayerView) {
              // now that I know all my layer views are ready I can do things with them
            })
          })
        })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did see the following and was thinking it would be clearer to just to do this 3 times&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var layerView = await view.whenLayerView(layer);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but got an error message that said "await is only valid in async functions and the top level bodies of modules".&amp;nbsp; I saw the following&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;at the top but don't really understand when I have to use it since most samples don't use it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;require([...], function (...) {

(async () =&amp;gt; {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 03:26:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-ensure-multiple-layerviews-are-ready/m-p/1036447#M72049</guid>
      <dc:creator>GaryB</dc:creator>
      <dc:date>2021-03-15T03:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to ensure multiple LayerViews are ready</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-ensure-multiple-layerviews-are-ready/m-p/1036625#M72062</link>
      <description>&lt;P&gt;Here's a solution from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript/when-featurelayer-done-drawing/m-p/548913#M51086" target="_blank"&gt;Solved: Re: When featurelayer done drawing - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 14:32:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-ensure-multiple-layerviews-are-ready/m-p/1036625#M72062</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-15T14:32:03Z</dc:date>
    </item>
  </channel>
</rss>

