Ну вот на вскидку как это можно закодить:
const responseHasError = (response) => response.error !== 0;
const queryParam$ = this.activatedRoute.queryParams.pipe(take(1), pluck('paramName'));
const [hasParam$, noParam$] = partition(queryParam$, Boolean);
hasParam$
.pipe(
mergeMap(param => this.retrieveData(param))
)
.subscribe();
const pingServerWhenNoParam$ = noParam$.pipe(mergeMap(() => this.pingServer()));
const [noParamAndHasServerError$, noParamAndNoServerError$] = partition(pingServerWhenNoParam$, responseHasError);
noParamAndNoServerError$
.pipe(
// Logic here
)
.subscribe();
noParamAndHasServerError$
.subscribe(() => this.router.navigate(['/other-page']));