I have a sequial list of observables is requiring sequencial execution (these are in concat operator but I can remove in forkjoin), but when error is happening I need to stop the sequential results. How to abort the remaining observables when any observable is throwing error?
concat( // This could be any operator, the execution should be in requence
verifyToken,
// subscribed after first completes
verifyUser,
verificationWithError, // Cancel the fourth one because we have error in third observable
// subscribed after second completes
checkRoles
)
.pipe(
map((printOnlyTheGoodOnes) => {
return printOnlyTheGoodOnes;
}),
catchError((_) => of('no more requests!!!'))
)
// should log: 1, 2, 3, 4, 5
.subscribe(console.log);