<?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 Problem with Deferred(s) in Loop in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151873#M14125</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;The following code will execute fine with only one deferred, but more than one, 'all.then()' never executes.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Overall, I am trying to validate a set of geometries to ensure they are not too big before adding to the map)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Any help would be very much appreciated.&amp;nbsp; Thanks!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var defListArray = [];&lt;BR /&gt;array.forEach(layer.featureSet.features, function (feat) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var geom = feat.geometry;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; defListArray.push(that.validateFieldSize(geom)); &lt;BR /&gt;});&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;STRONG style="color: #3d3d3d;"&gt;&lt;SPAN style="color: #2873ee;"&gt;//var defList = new DeferredList(defListArray);&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;SPAN style="color: #2873ee;"&gt;&lt;SPAN style="color: #3d3d3d;"&gt; //&lt;/SPAN&gt;Does not work with DeferredList as well; same behavior&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;all(defListArray).then(lang.hitch(this, function (results) {&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;SPAN style="color: #2873ee;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;//PROBLEM: This code only executes when there is only one Deferred in array&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #2873ee;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // I want to know when&lt;/SPAN&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('deferred list', results);&lt;BR /&gt;}));&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #2873ee;"&gt;//...//&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;validateFieldSize: function(fieldGeom){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var that = this;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = new Deferred();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService = new GeometryService(this.geometryServiceURL);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService.on('areas-and-lengths-complete', lang.hitch(this, 'showVerifyiedFieldGeometryResults', deferred));&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #2873ee;"&gt; //setup the parameters for the areas and lengths operation&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var areasAndLengthParams = new AreasAndLengthsParameters();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.lengthUnit = GeometryService.UNIT_FOOT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.areaUnit = GeometryService.UNIT_ACRES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.calculationType = 'geodesic';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService.simplify([fieldGeom], function (simplifiedGeometries) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.polygons = simplifiedGeometries;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; that.geometryService.areasAndLengths(areasAndLengthParams);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #2873ee;"&gt;&lt;STRONG&gt; //deferred.resolve('QUICK RESOLVE'); &lt;/STRONG&gt; //'all().then()' executes if I comment this line out...&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return deferred;&lt;BR /&gt;},&lt;BR /&gt;showVerifyiedFieldGeometryResults: function(deferred, results){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var acres = Math.floor(results.result.areas[0]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #2873ee;"&gt;//NOTE: Check acres to ensure the feature is not too big... code omitted...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('geometry results'); &lt;SPAN style="color: #2873ee;"&gt; //this line always executes so it appears something is wrong with the Deferreds...&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.resolve('Verified Field Size: ' + acres);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 May 2015 21:24:43 GMT</pubDate>
    <dc:creator>JerryGarcia</dc:creator>
    <dc:date>2015-05-27T21:24:43Z</dc:date>
    <item>
      <title>Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151873#M14125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;The following code will execute fine with only one deferred, but more than one, 'all.then()' never executes.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Overall, I am trying to validate a set of geometries to ensure they are not too big before adding to the map)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Any help would be very much appreciated.&amp;nbsp; Thanks!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var defListArray = [];&lt;BR /&gt;array.forEach(layer.featureSet.features, function (feat) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var geom = feat.geometry;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; defListArray.push(that.validateFieldSize(geom)); &lt;BR /&gt;});&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;STRONG style="color: #3d3d3d;"&gt;&lt;SPAN style="color: #2873ee;"&gt;//var defList = new DeferredList(defListArray);&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;SPAN style="color: #2873ee;"&gt;&lt;SPAN style="color: #3d3d3d;"&gt; //&lt;/SPAN&gt;Does not work with DeferredList as well; same behavior&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;all(defListArray).then(lang.hitch(this, function (results) {&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;SPAN style="color: #2873ee;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;//PROBLEM: This code only executes when there is only one Deferred in array&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #2873ee;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // I want to know when&lt;/SPAN&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('deferred list', results);&lt;BR /&gt;}));&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #2873ee;"&gt;//...//&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;validateFieldSize: function(fieldGeom){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var that = this;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = new Deferred();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService = new GeometryService(this.geometryServiceURL);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService.on('areas-and-lengths-complete', lang.hitch(this, 'showVerifyiedFieldGeometryResults', deferred));&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #2873ee;"&gt; //setup the parameters for the areas and lengths operation&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var areasAndLengthParams = new AreasAndLengthsParameters();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.lengthUnit = GeometryService.UNIT_FOOT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.areaUnit = GeometryService.UNIT_ACRES;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.calculationType = 'geodesic';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService.simplify([fieldGeom], function (simplifiedGeometries) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; areasAndLengthParams.polygons = simplifiedGeometries;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; that.geometryService.areasAndLengths(areasAndLengthParams);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #2873ee;"&gt;&lt;STRONG&gt; //deferred.resolve('QUICK RESOLVE'); &lt;/STRONG&gt; //'all().then()' executes if I comment this line out...&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return deferred;&lt;BR /&gt;},&lt;BR /&gt;showVerifyiedFieldGeometryResults: function(deferred, results){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var acres = Math.floor(results.result.areas[0]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #2873ee;"&gt;//NOTE: Check acres to ensure the feature is not too big... code omitted...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('geometry results'); &lt;SPAN style="color: #2873ee;"&gt; //this line always executes so it appears something is wrong with the Deferreds...&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.resolve('Verified Field Size: ' + acres);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 21:24:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151873#M14125</guid>
      <dc:creator>JerryGarcia</dc:creator>
      <dc:date>2015-05-27T21:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151874#M14126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks confusing to me:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;this.geometryService.on('areas-and-lengths-complete', lang.hitch(this, 'showVerifyiedFieldGeometryResults', deferred));&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I don't see in the source or docs that hitch takes a 3rd parameter. It looks like you are trying to pass it as a token.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;You could rewrite it like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;this.geometryService.on('areas-and-lengths-complete', this.showVerifyiedFieldGeometryResults(deferred));&lt;/SPAN&gt;
&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;//updated&lt;/SPAN&gt;
showVerifyiedFieldGeometryResults: function(deferred){
&amp;nbsp;&amp;nbsp; return function(results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var acres = Math.floor(results.result.areas[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #2873ee;"&gt;//NOTE: Check acres to ensure the feature is not too big... code omitted...&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log('geometry results'); &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #2873ee;"&gt;//this line always executes so it appears something is wrong with the Deferreds...&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.resolve('Verified Field Size: ' + acres);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
}&lt;/PRE&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I would try that&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151874#M14126</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T08:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151875#M14127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/8190" target="_blank"&gt;Jerry Garcia&lt;/A&gt;​ Looks like deferred hell to me. Here's my take on that problem all with 2 sever calls and no deferreds:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;constructor: function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService = new GeometryService(this.geometryServiceURL);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.areasAndLengthParams = lang.mixin(new AreasAndLengthsParameters(), {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lengthUnit: GeometryService.UNIT_FOOT,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; areaUnit: GeometryService.UNIT_ACRES,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; calculationType: 'geodesic'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
},


validate: function (layer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var geometries = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; array.forEach(layer.featureSet.features, function (feat) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geometries.push(feat.geometry);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService.simplify(geometries, lang.hitch(this, '_simplifyResult'), lang.hitch(this, '_simplifyError'));
},


_simplifyResult: function (results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.areasAndLengthParams.polygons = results;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.geometryService.areasAndLengths(this.areasAndLengthParams, lang.hitch(this, '_areasAndLengthsResult', results), lang.hitch(this, '_areasAndLengthsError'));
},
_simplifyError: function (error) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // handle error
},


_areasAndLengthsResult: function (simplifiedGeometries, results) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // i'm making a HUGE assumption here the array of areas is in the same order as geometries passed to areasAndLengths
&amp;nbsp;&amp;nbsp;&amp;nbsp; array.forEach(simplifiedGeometries, function (simpGeom, idx) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var acres = Math.floor(result.areas[idx]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do your check here
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, this);
},
_areasAndLengthsError: function (error) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // handle error
}&lt;/PRE&gt;&lt;P&gt;Also check out &lt;A href="https://developers.arcgis.com/javascript/jsapi/esri.geometry.geometryengineasync-amd.html" title="https://developers.arcgis.com/javascript/jsapi/esri.geometry.geometryengineasync-amd.html" rel="nofollow noopener noreferrer" target="_blank"&gt;esri/geometry/geometryEngineAsync | API Reference | ArcGIS API for JavaScript&lt;/A&gt; . It's all on the client now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:08:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151875#M14127</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2021-12-11T08:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151876#M14128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This code works, but with the same results and problem I am having.&amp;nbsp; This code may be cleaner, but it works the same as using lang.hitch.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 15:29:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151876#M14128</guid>
      <dc:creator>JerryGarcia</dc:creator>
      <dc:date>2015-05-28T15:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151877#M14129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree this is a good approach, but I'd like to process one feature at a time.&amp;nbsp; I have additional verification rules I need to process on each feature before adding to the map.&amp;nbsp; I simplified the code for this example.&amp;nbsp; I'm really interested in finding out why the all.then() does not execute when I can see all of the deferreds in the array are resolved()?&amp;nbsp; But, it does execute, when there is only one deferred. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 18:25:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151877#M14129</guid>
      <dc:creator>JerryGarcia</dc:creator>
      <dc:date>2015-05-28T18:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151878#M14130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess I don't understand why you need deferreds when the geom service methods return deferreds themselves. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var promises = [];

array.forEach(layer.featureSet.features, function (feat) {
&amp;nbsp; promises.push(this.geometryService.simplify([feat.geometry]));
}, this);

all(promises).then(callback, errback);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the same for areasAndLengths.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:08:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151878#M14130</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2021-12-11T08:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Deferred(s) in Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151879#M14131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&amp;nbsp; Your suggestion helped me figure it out. Passing a Deferred to the callback like this does not work called multiple times: this.geometryService.on('areas-and-lengths-complete', lang.hitch(this, 'showVerifyiedFieldGeometryResults', deferred)); Instead, this works: geometryService.areasAndLengths(params, function(results){ ... deferred.resolve(); }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 19:45:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/problem-with-deferred-s-in-loop/m-p/151879#M14131</guid>
      <dc:creator>JerryGarcia</dc:creator>
      <dc:date>2015-05-28T19:45:33Z</dc:date>
    </item>
  </channel>
</rss>

