title: Dojo Memory Store Periodic Refresh
body: <p>I have a dojo method to make an xhrRequest to get the latest list of items from DB and i do it periodically using <code>setInterval()</code>. Is there any other better way without using <code>setInterval()</code> that would automatically update the Memory store whenever a new item is added to the DB?.. The current code is below</p>
  
  <pre><code>&lt;div data-dojo-type="dojo/store/Memory"
               data-dojo-id="dataStore"&gt;
              &lt;script type="dojo/method"&gt;  
  var myStore = this;
  setInterval(function(){ 
  require(["dojo/request/xhr"], function(xhr){
    xhr("myurl", {
      handleAs: "json"
    }).then(function(data){
  if (data &amp;&amp; data.length &gt; 0) {   
                          myStore.setData(data);
                          }
    }, function(err){
      // Handle the error condition
    }, function(evt){
      // Handle a progress event from the request if the
      // browser supports XHR2
    });
  });
  }, 2000);                  
              &lt;/script&gt;
          &lt;/div&gt;
  </code></pre>