Skip to content

Instantly share code, notes, and snippets.

View nkmdev's full-sized avatar
:octocat:
I may be slow to respond.

Nitin Mishra nkmdev

:octocat:
I may be slow to respond.
  • 18:03 (UTC +05:30)
View GitHub Profile
import { timer, from } from 'rxjs'
import { map, concatMap, filter, take } from 'rxjs/operators'
pollUntilTaskFinished(taskId) {
timer(0, 500)
.pipe(concatMap(() => from(fetch(`/tasks/${taskId}`))
.pipe(map(response => response.json())))
)
.pipe(filter(backendData => backendData.processing === false))
.pipe(take(1))
.subscribe(() => pollingFinishedFor(taskId))