Используя Promise
:
myServices.firstMethod(id).toPromise().then(({ params }) => {
return myServices.secondMethod(params).toPromise();
}).then((secondMethodRes) => {
console.log(secondMethodRes);
});
Используя mergeMap || switchMap || concatMap || exhaustMap
:
import { mergeMap, switchMap, concatMap, exhaustMap } from 'rxjs/operators';
myServices.firstMethod(id).pipe(
mergeMap(({ params }) => myServices.secondMethod(params))
// ИЛИ
switchMap(({ params }) => myServices.secondMethod(params))
// ИЛИ
concatMap(({ params }) => myServices.secondMethod(params))
// ИЛИ
exhaustMap(({ params }) => myServices.secondMethod(params))
).subscribe((secondMethodRes) => {
console.log(secondMethodRes);
});
Используя map + mergeAll || switchAll || concatAll || exhaust
:
import { map, mergeAll } from 'rxjs/operators';
myServices.firstMethod(id).pipe(
map(({ params }) => myServices.secondMethod(params)),
mergeAll()
// ИЛИ
switchAll()
// ИЛИ
concatAll()
// ИЛИ
exhaust()
).subscribe((secondMethodRes) => {
console.log(secondMethodRes);
});