How do I access the resultB
in the tap
operator after it was switchMap
ped ?
streamA$.pipe(
switchMap(resultA => {
const streamB$ = resultA ? streamB1$ : streamB2$;
return streamB$.pipe( // <- nesting
switchMap(resultB => loadData(resultB)),
tap(data => {
// how do I access resultB here?
})
);
})
);
bonus question: Is it possible to avoid the nesting here, and chain the whole flow under single pipe?
Please consider the following example: