升级到RC 6和RxJS Beta 11后,flatMap丢失 [英] flatMap missing after upgrading to RC 6 and RxJS Beta 11
问题描述
升级到RC6和rxjs@5.0.0-beta.11之后,我似乎缺少了Observable对象的一些扩展.
After upgrading to RC6 and rxjs@5.0.0-beta.11 I seem to be missing a few extensions from Observable object.
flatMap运算符不见了,mergeMap也不在这里.我现在只看到一些操作员.知道我想念什么吗?
flatMap operator is gone, mergeMap is also not here. I only see a few operators now. Any idea what I'm missing?
推荐答案
我想现在您需要分别导入运算符.如果你看里面
I guess now you need to import operators individually. If you look inside
node_modules/rxjs/add/operator/mergeMap
您应该看到mergeMap.d.ts
.内容是
declare module '../../Observable' {
interface Observable<T> {
flatMap: MergeMapSignature<T>;
mergeMap: MergeMapSignature<T>;
}
}
因此,mergeMap
模块同时声明了flatMap
和mergeMap
.这样您就可以导入该文件
So the mergeMap
module declares both flatMap
and mergeMap
. So you can just import that file
import 'rxjs/add/operator/mergeMap`;
If you're concerned about style (i.e having to import this in all the files you need it), you can check out the plunker example from the Angular tutorial, where they import all the operators the application needs into a file, and just import that file into the app.component file. You should only need to import this in one place. From my experience, when unit testing, where the AppComponent is not involved, I had to import that file into each of the test files.
这篇关于升级到RC 6和RxJS Beta 11后,flatMap丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!