<?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 Re: Using reactiveUtils.when inside Promise.all() in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1204745#M78378</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/584788"&gt;@JustinKirtz1&lt;/a&gt;hmm, try replacing reactiveUtils.when() with whenOnce() since that returns a promise and works with truthy values, if you go that route you also won't need to set 'once: true'. In comparison, reactiveUtils.when() returns a WatchHandle. Check out the doc section on "&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html#watchandles-and-promises" target="_self"&gt;WatchHandles and Promises&lt;/A&gt;" and also check the "&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html#truthy-values" target="_self"&gt;Working with truthy values&lt;/A&gt;" section right below that.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2022 22:37:42 GMT</pubDate>
    <dc:creator>AndyGup</dc:creator>
    <dc:date>2022-08-19T22:37:42Z</dc:date>
    <item>
      <title>Using reactiveUtils.when inside Promise.all()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1204617#M78374</link>
      <description>&lt;P&gt;I'm trying to convert my pre-4.24 code using watchUtils to now use reactiveUtils. I have a tool that lets a user place a point on the map, waits for four address point feature layers to load, waits for them to stop updating, then finds the closest address to the point they created. The code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Promise.all([
                        appConfig.activeView.whenLayerView(greenvilleCountyAddresses),
                        appConfig.activeView.whenLayerView(andersonCountyAddresses),
                        appConfig.activeView.whenLayerView(pickensCountyAddresses),
                        appConfig.activeView.whenLayerView(laurensCountyAddresses),
                    ]).then(([layerView1, layerView2, layerView3, layerView4]) =&amp;gt; {
                        return Promise.all(
                            [
                                watchUtils.whenFalseOnce(layerView1, "updating"),
                                watchUtils.whenFalseOnce(layerView2, "updating"),
                                watchUtils.whenFalseOnce(layerView3, "updating"),
                                watchUtils.whenFalseOnce(layerView4, "updating"),
                            ]
                        );
                    }).then(([layerView1, layerView2, layerView3, layerView4]) =&amp;gt; {
                        addVehicleIncident_FeatureLayerView_GreenvilleCountyAddresses = layerView1.target;
                        addVehicleIncident_FeatureLayerView_AndersonCountyAddresses = layerView2.target;
                        addVehicleIncident_FeatureLayerView_PickensCountyAddresses = layerView3.target;
                        addVehicleIncident_FeatureLayerView_LaurensCountyAddresses = layerView4.target;
                        findClosestAddress_addVehicleIncident(addressSelectorBuffer, newAddVehicleIncidentFeature, greenvilleCountyAddresses, andersonCountyAddresses, pickensCountyAddresses, laurensCountyAddresses)
                    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to the docs PromisedWatchHandle is now deprecated so the Promise.all isn't working anymore when I try something like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Promise.all([
                        appConfig.activeView.whenLayerView(greenvilleCountyAddresses),
                        appConfig.activeView.whenLayerView(andersonCountyAddresses),
                        appConfig.activeView.whenLayerView(pickensCountyAddresses),
                        appConfig.activeView.whenLayerView(laurensCountyAddresses),
                    ]).then(([layerView1, layerView2, layerView3, layerView4]) =&amp;gt; {
                        return Promise.all(
                            [
                                reactiveUtils.when(() =&amp;gt; !layerView1.updating,() =&amp;gt; {},{once: true}),
                                reactiveUtils.when(() =&amp;gt; !layerView2.updating,() =&amp;gt; {},{once: true}),
                                reactiveUtils.when(() =&amp;gt; !layerView3.updating,() =&amp;gt; {},{once: true}),
                                reactiveUtils.when(() =&amp;gt; !layerView4.updating,() =&amp;gt; {},{once: true}),
                            ]
                        );
                    }).then(([layerView1, layerView2, layerView3, layerView4]) =&amp;gt; {
                        addVehicleIncident_FeatureLayerView_GreenvilleCountyAddresses = layerView1.target;
                        addVehicleIncident_FeatureLayerView_AndersonCountyAddresses = layerView2.target;
                        addVehicleIncident_FeatureLayerView_PickensCountyAddresses = layerView3.target;
                        addVehicleIncident_FeatureLayerView_LaurensCountyAddresses = layerView4.target;
                        findClosestAddress_addVehicleIncident(addressSelectorBuffer, newAddVehicleIncidentFeature, greenvilleCountyAddresses, andersonCountyAddresses, pickensCountyAddresses, laurensCountyAddresses)
                    });&lt;/LI-CODE&gt;&lt;P&gt;I'm not the best with Promises so any help/advice would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 16:55:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1204617#M78374</guid>
      <dc:creator>JustinKirtz1</dc:creator>
      <dc:date>2022-08-19T16:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using reactiveUtils.when inside Promise.all()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1204745#M78378</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/584788"&gt;@JustinKirtz1&lt;/a&gt;hmm, try replacing reactiveUtils.when() with whenOnce() since that returns a promise and works with truthy values, if you go that route you also won't need to set 'once: true'. In comparison, reactiveUtils.when() returns a WatchHandle. Check out the doc section on "&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html#watchandles-and-promises" target="_self"&gt;WatchHandles and Promises&lt;/A&gt;" and also check the "&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html#truthy-values" target="_self"&gt;Working with truthy values&lt;/A&gt;" section right below that.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 22:37:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1204745#M78378</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2022-08-19T22:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using reactiveUtils.when inside Promise.all()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1205038#M78394</link>
      <description>&lt;P&gt;Andy,&lt;/P&gt;&lt;P&gt;This worked, I just had to switch my code around a bit.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Promise.all([
                        appConfig.activeView.whenLayerView(greenvilleCountyAddresses),
                        appConfig.activeView.whenLayerView(andersonCountyAddresses),
                        appConfig.activeView.whenLayerView(pickensCountyAddresses),
                        appConfig.activeView.whenLayerView(laurensCountyAddresses),
                    ]).then(([layerView1, layerView2, layerView3, layerView4]) =&amp;gt; {
                        addVehicleIncident_FeatureLayerView_GreenvilleCountyAddresses = layerView1;
                        addVehicleIncident_FeatureLayerView_AndersonCountyAddresses = layerView2;
                        addVehicleIncident_FeatureLayerView_PickensCountyAddresses = layerView3;
                        addVehicleIncident_FeatureLayerView_LaurensCountyAddresses = layerView4;
                        return Promise.all(
                            [
                                reactiveUtils.whenOnce(() =&amp;gt; layerView1.updating === false),
                                reactiveUtils.whenOnce(() =&amp;gt; layerView2.updating === false),
                                reactiveUtils.whenOnce(() =&amp;gt; layerView3.updating === false),
                                reactiveUtils.whenOnce(() =&amp;gt; layerView4.updating === false),
                            ]
                        );
                    }).then(() =&amp;gt; {
                        findClosestAddress_addVehicleIncident(addressSelectorBuffer, newAddVehicleIncidentFeature, greenvilleCountyAddresses, andersonCountyAddresses, pickensCountyAddresses, laurensCountyAddresses)
                    });&lt;/LI-CODE&gt;&lt;P&gt;Thanks for the help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 15:52:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-reactiveutils-when-inside-promise-all/m-p/1205038#M78394</guid>
      <dc:creator>JustinKirtz1</dc:creator>
      <dc:date>2022-08-22T15:52:49Z</dc:date>
    </item>
  </channel>
</rss>

