Skip to content

Instantly share code, notes, and snippets.

@ipcrm
Created February 20, 2019 15:57
Show Gist options
  • Save ipcrm/e74cb51e43437848de2e0b4083591552 to your computer and use it in GitHub Desktop.
Save ipcrm/e74cb51e43437848de2e0b4083591552 to your computer and use it in GitHub Desktop.
polling
// Starting polling
const result = new Deferred<string>();
const timer = setInterval(async () => {
...
const deploymentStatus = await httpClient.exchange<any>(`${someurl}/${somepath}`, {
method: HttpMethod.Get,
headers: {
Accept: "application/json",
},
});
...
if (somecondition) {
result.resolve(somevalue);
}
}, pollInternal);
// Wait for polling to finish
const status = await result.promise;
clearInterval(timer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment