我遇到了一段代码,它有一个管道运算符,但没有链。有必要吗?或者对它有什么好处吗?
带管道
this.store.pipe(select(currentUser)).subscribe(authState => {});
不带管道
this.store.select(currentUser).subscribe(authState => {});
嗯,这有点令人困惑。 在 NgRx 6 中,select()
方法已被弃用,取而代之的是select()
运算符。 https://github.com/ngrx/platform/blob/6.1.2/modules/store/src/store.ts#L22-L24。
但是,自 NgRx 7 以来,它未被弃用:
- https://github.com/ngrx/platform/pull/1361
- https://github.com/ngrx/platform/pull/1382
-
https://github.com/ngrx/platform/blob/master/CHANGELOG.md#bug-fixes-16存储:从Store.select
中删除弃用
NgRx 的官方文档使用的是select()
运算符,但 #1361 中的人们建议使用select()
方法。