NgRx:store.select是否需要RxJS管道运算符?

时间:2019-12-27 14:55:45

标签: angular rxjs ngrx ngrx-store

我遇到了一段带有管道运算符的代码,但是没有链。有必要吗?或根本没有好处?

带管道

this.store.pipe(select(currentUser)).subscribe(authState => {});

无管道

this.store.select(currentUser).subscribe(authState => {});

1 个答案:

答案 0 :(得分:2)

嗯,这有点令人困惑。在NgRx 6中,不推荐使用select()方法,而推荐使用select()运算符。 https://github.com/ngrx/platform/blob/6.1.2/modules/store/src/store.ts#L22-L24

但是,自NgRx 7起,该版本已被弃用:

NgRx的官方文档正在使用select()运算符,但是#1361的人们建议使用select()方法。