Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is an extension to the JavaScript language called StratifiedJS. It runs in every browser, and it allows you to handle asynchronous calls like that in a linear way.</p> <p>You can enable Stratified JavaScript e.g. by including Oni Apollo ( <a href="http://onilabs.com/docs" rel="nofollow noreferrer">http://onilabs.com/docs</a> ) in your webpage like:</p> <pre><code>&lt;script src="http://code.onilabs.com/latest/oni-apollo.js"&gt;&lt;/script&gt; &lt;script type="text/sjs"&gt; your StratifiedJS code here &lt;/script&gt; </code></pre> <p>And your code would look something like:</p> <pre><code>var http = require("http"); // a module wrapping XHR, part of Apollo for(i=0;i&lt;numOfDataObjects;i++) { //get the data var data = http.get(url); // and do something with it } </code></pre> <p>But that would execute all requests sequentially, you can also execute all requests in parallel (so the browser can make multiple connections at once) and continue on the next line when they're all done:</p> <pre><code>function handleParallelRequests(urls) { if (!urls.length) return; waitfor { var data = require('http').get(urls[0]); // and do something with it  } and { // in parallel, do remaining requests: // continue with the urls without the first we just handled. handleParallelRequests(urls.slice(1)); } } handleParallelRequest(myurls); // all request are finished when you get here. </code></pre> <p>the waitfor/and keyword is explained at <a href="http://stratifiedjs.org/sjsdocs" rel="nofollow noreferrer">http://stratifiedjs.org/sjsdocs</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload