Skip to content

Instantly share code, notes, and snippets.

@rubenmarcus
Created April 18, 2020 14:35
Show Gist options
  • Select an option

  • Save rubenmarcus/cd9e9e2aa0de1a395f0cc1a59dd50ef1 to your computer and use it in GitHub Desktop.

Select an option

Save rubenmarcus/cd9e9e2aa0de1a395f0cc1a59dd50ef1 to your computer and use it in GitHub Desktop.
const statusCheckEpic = action$ =>
action$.filter(action => action.type === POLL_SERVICE_STATUS)
.flatMap(() =>
most.periodic(1000)
.flatMap(() =>
most.fromPromise(checkServiceStatus())
.filter(response => response.data.status !== STATUS.IN_PROGRESS)
.map(response => {
if (response.data.status === STATUS.COMPLETE) {
return serviceComplete()
}
return serviceError()
})
.recoverWith(error => {
return most.of(serviceError(error))
})
)
.takeUntil(action$.filter(action => action.type === NAVIGATE_BACK))
.take(1)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment