缺少 rxjs 平面图 [英] rxjs flatmap missing
本文介绍了缺少 rxjs 平面图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试链接多个 rx.js observables 并传递数据.Flatmap
应该是拟合运算符,但导入了
I try to chain multiple rx.js observables and pass the data. Flatmap
should be the fitting operator but with an import of
import { Observable } from 'rxjs/Observable';
未找到:
Error TS2339: Property 'flatmap' does not exist on type 'Observable<Coordinates>'
使用的是 rx.js 的 5.0.0-beta.6
版本.
Version 5.0.0-beta.6
of rx.js is used.
public getCurrentLocationAddress():Observable<String> {
return Observable.fromPromise(Geolocation.getCurrentPosition())
.map(location => location.coords)
.flatmap(coordinates => {
console.log(coordinates);
return this.http.request(this.geoCodingServer + "/json?latlng=" + coordinates.latitude + "," + coordinates.longitude)
.map((res: Response) => {
let data = res.json();
return data.results[0].formatted_address;
});
});
}
推荐答案
事实证明答案很简单:
这个操作符在这个版本的rxjs中叫做mergeMap
the operator is called mergeMap
in this version of rxjs
此外,您可能需要使用 import 'rxjs/add/operator/mergeMap'
.
Furthermore, you might have to use import 'rxjs/add/operator/mergeMap'
.
这篇关于缺少 rxjs 平面图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文