【发布时间】:2018-11-09 06:52:13
【问题描述】:
为了改进我的应用程序状态管理,我查看了 ngrx 演示应用程序。
在example-app/app/core/containers/app.component.ts 中,组件包含两个在构造函数中初始化的可观察对象。 observables 被初始化为
constructor(private store: Store<fromRoot.State>) {
/**
* Selectors can be applied with the `select` operator which passes the state
* tree to the provided selector
*/
this.showSidenav$ = this.store.pipe(select(fromRoot.getShowSidenav));
this.loggedIn$ = this.store.pipe(select(fromAuth.getLoggedIn));
}
我不明白的是,如何在那里使用 fromAuth.getLoggedIn。注入的存储是从Root.State 键入的。 root-reducer example-app/app/reducers/index.ts 与 auth-state 没有连接。 auth-state example-app/app/auth/reducers/index.ts 确实扩展了 root-state,所以我可以理解这些对 auth-state 的调用是有效的,但我不明白它是如何工作的。
【问题讨论】:
标签: ngrx ngrx-store