<?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 Portal.queryItems callback function execution timing in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220228#M20458</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got the following scenario...I'm querying my local Portal for certain items and then I am processing them using a callback function, as soon as the query returns them. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;globalVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //...

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function doSomeOtherStuff() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do some other stuff
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //requires the updated globalVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Portal.queryItems(params).then(processItems)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; doSomeOtherStuff();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function processItems(items) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do something
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //update globalVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //...&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Giving this is an async call, other things (i.e. doSomeOtherStuff()) carry on while the query is finalised and the items processed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I wait for the processItems() to complete before doing anything else (so a synchronous operation in a sense)?&lt;/P&gt;&lt;P&gt;The processItems function updates a global variable that I need to use in doSomeOtherStuff() and carry on with the logic. I can't execute doSomeOtherStuff() within processItems() because due to the nature of it, it will take doSomeOtherStuff() out of scope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense, I've tried to simplify as much as possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:44:34 GMT</pubDate>
    <dc:creator>NartTamash</dc:creator>
    <dc:date>2021-12-11T10:44:34Z</dc:date>
    <item>
      <title>Portal.queryItems callback function execution timing</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220228#M20458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got the following scenario...I'm querying my local Portal for certain items and then I am processing them using a callback function, as soon as the query returns them. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;globalVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //...

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function doSomeOtherStuff() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do some other stuff
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //requires the updated globalVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Portal.queryItems(params).then(processItems)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; doSomeOtherStuff();

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function processItems(items) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //do something
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //update globalVariable
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //...&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Giving this is an async call, other things (i.e. doSomeOtherStuff()) carry on while the query is finalised and the items processed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I wait for the processItems() to complete before doing anything else (so a synchronous operation in a sense)?&lt;/P&gt;&lt;P&gt;The processItems function updates a global variable that I need to use in doSomeOtherStuff() and carry on with the logic. I can't execute doSomeOtherStuff() within processItems() because due to the nature of it, it will take doSomeOtherStuff() out of scope.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense, I've tried to simplify as much as possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220228#M20458</guid>
      <dc:creator>NartTamash</dc:creator>
      <dc:date>2021-12-11T10:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Portal.queryItems callback function execution timing</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220229#M20459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nart,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; This is where a Deferred comes into play.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://dojotoolkit.org/reference-guide/1.10/dojo/Deferred.html" title="https://dojotoolkit.org/reference-guide/1.10/dojo/Deferred.html"&gt;dojo/Deferred — The Dojo Toolkit - Reference Guide&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2016 13:52:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220229#M20459</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-05-11T13:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: Portal.queryItems callback function execution timing</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220230#M20460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right...so what I needed was a chained promise. Sort of tried that before but didn't work cause I didn't know what I was doing &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/confused.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Always on the watch, Robert! Appreciate it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 May 2016 14:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/portal-queryitems-callback-function-execution/m-p/220230#M20460</guid>
      <dc:creator>NartTamash</dc:creator>
      <dc:date>2016-05-11T14:57:03Z</dc:date>
    </item>
  </channel>
</rss>

