我有以下代码:
this._loadingStateSubscription = combineLatest(
select(fromTreeSelector.selectLoadingState),
select(fromFinanceSelector.selectLoadingState),
(isTreeLoading, isFinanceLoading) => {
return isTreeLoading && isFinanceLoading;
}
)
.subscribe(isLoading => this.isLoading = !isLoading);
问题是,我的订阅没有根据更改进行更新。但下面我有这段代码
this.store.pipe(select(fromTreeSelector.selectLoadingState))
.subscribe((isLoading) => {
// this.isLoading = isLoading;
console.log("isLoading", isLoading)
});
this._loadingStateSubscription = this.store.pipe(select(fromFinanceSelector.selectLoadingState))
.subscribe((isLoading) => {
// this.isLoading = isLoading;
console.log("isLoading", isLoading)
});
每次更新时我都会收到一条控制台日志消息。
两个选择器如下所示:
export const selectLoadingState = (state: AppState) => state.structures.isLoading;
对此有什么想法吗?
最佳答案
好吧,我想通了:
this.store.select(fromTreeSelector.selectLoadingState),
this.store.select(fromFinanceSelector.selectLoadingState)
我必须添加 this.store
现在它正在工作。
关于javascript - mixLatest 与 ngrx 不更新更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50348685/