<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to use applyAsync() in javascript</title><link>https://www.aras.com/community/f/development/6186/how-to-use-applyasync-in-javascript</link><description>I am using javascript code to fetch items of some itemType, I see two method in aras - apply() and applyAsync(). 
 How do i use applyAsync()? An example of working code would be helpful. 
 
 Thanks 
 Vinay</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to use applyAsync() in javascript</title><link>https://www.aras.com/community/thread/3276?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 17:59:55 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:4c1a7d32-addf-451d-bd75-9fa422372717</guid><dc:creator>Christopher Gillis</dc:creator><description>&lt;p&gt;Hi Vinay,&lt;/p&gt;
&lt;p&gt;I answered &lt;a href="/f/development/3925/javascript-innovator-applymethod-async"&gt;another forum post&lt;/a&gt; with a use case for applyAsync() that I wanted to share here. The users there were trying to display a spinner to let the users know that a long item query was running. The code in the Gist below uses applyAsync() to satisfy this use case by starting the spinner, doing an apply with applyAsync(), and then stopping the spinner after it returns.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://gist.github.com/cgillis-aras/ea18abe9c0e94c6e858c544f5d9c077e"&gt;https://gist.github.com/cgillis-aras/ea18abe9c0e94c6e858c544f5d9c077e&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The difference between &lt;em&gt;apply()&lt;/em&gt; and &lt;em&gt;applyAsync()&lt;/em&gt; is that &lt;em&gt;apply()&lt;/em&gt; halts the execution of your code until the query is completed at which point it will return an item containing the results of your query. &lt;em&gt;applyAsync()&lt;/em&gt; on the other hand returns a Promise that can eventually handle the result of the query and does not halt your code. There&amp;#39;s a number of different articles available online (like &lt;a href="https://javascript.info/promise-basics"&gt;this one&lt;/a&gt;) that explain Promises, asynchronous code, and the benefits of using them.&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;
&lt;p&gt;Christopher Gillis&lt;/p&gt;
&lt;p&gt;Aras Labs Software Engineer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use applyAsync() in javascript</title><link>https://www.aras.com/community/thread/3261?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 14:47:20 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:8c272c09-0003-4103-a889-f8f03d945b15</guid><dc:creator>cogres</dc:creator><description>&lt;p&gt;Hi Vinay,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the method &amp;quot;cui_common_favoritesearch_init&amp;quot; (it was included in my standard Innovator 12.0 installation) contains some code using applyAsync():&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;iomItem.applyAsync()&lt;br /&gt;&amp;nbsp;&amp;nbsp; .then(renderList)&lt;br /&gt;&amp;nbsp;&amp;nbsp; .catch(function() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return function(dataItem) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataItem.roots = [];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataItem.data = new Map();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataItem.disabled = true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return dataItem;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; })&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .then(updateTitlebar);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;C&lt;br /&gt;&lt;code&gt;&lt;code&gt;&lt;/code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>