Well, one thing you probably don't want to do is let the error do it before the top-level stream. Even if you execute catch
, you have effectively killed the top-level thread. Therefore, if your redirect does not perform hard forwarding, but not soft using something like a reactive router, you can no longer use this epic.
So, I would say that you want most of the logic to be encapsulated in switchMap
:
function withAuthorizedFlow(source) { return source .map(fetchAssetListSuccess)
Using let
above is completely optional, I threw it to clear the function. Essentially, although you want to contain an error in the internal thread so that it cannot stop the external. I'm not sure which ajax
library you are using, but you must also confirm that it will really return the Observable
chill, otherwise you will need to wrap it in a defer
block to retryWhen
work.
source share