假设我们有两个接口:
export interface IA{
something: string;
myprop: number;
}
export interface IB{
myprop: number;
}
我有一个方法应该调用从后端返回IA对象的端点,然后它应该调用另一个端点,然后将两个结果合并到IA对象中。以前我是这样做的:
GetA():Observable<IA>{
return this.httpClient
.get<IA>('somewhere')
.concatMap(a=>Observable.combineLatest(
Observable.of(a),
GetB(a)
))
.map([a,b]=>combineSomehowAandB(a,b))
}
rxjs
我被迫改用.pipe(operators[])。如何使用pipe()实现相同的功能?我试过了,但没用:
GetA():Observable<IA>{
return this.httpClient
.get<IA>('somewhere')
.pipe(
concatMap(a=>[Observable.of(a), GetB(a)]),
combineLatest(),
map([a,b]=>combineSomehowAandB(a,b))
);
}