I try to retry the request until the response has data using RxJS, at which point I would call a successful (or unsuccessful) handler, but I have problems with RxJS. Here is my current approach:
// ... redux-observable action observable
.mergeMap(() =>
fetchData()
.repeatWhen(response =>
response.takeWhile(({ data }) => !data.length)
.of(response)
)
)
.map(successFunction)
.catch(failureFunction);
Disclaimer: I'm completely new to RxJS ....
source
share