javascript - how to keep resolving Q promises when polling -


i'm trying poll endpoint , use q resolve request. understand can't q, once promise resolved it's done.

is there way can approach using q along polling?

my setup like:

class poller {   poll() {     const deferred = q.defer();      const promise = $.ajax({        //stuff      });      promise.done((resp) => {       // resolves once, how can keep resolving       // on future xhr calls?       deferred.resolve(resp);     });      promise.always(() => {       settimeout(() => {         this.poll.call(this);       }, 5000)     })      return deferred.promise;   }  }  const poller = new poller();  poller.poll().then((resp) => {   // keep trigging updates polling }) 

the whole point of promise can resolved once. structure looking event.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -