[英]combineLatest with ngrx not updating on changes
I have following code: 我有以下代码:
this._loadingStateSubscription = combineLatest(
select(fromTreeSelector.selectLoadingState),
select(fromFinanceSelector.selectLoadingState),
(isTreeLoading, isFinanceLoading) => {
return isTreeLoading && isFinanceLoading;
}
)
.subscribe(isLoading => this.isLoading = !isLoading);
the problem is, I the subscription is not updating on changes. 问题是,我的订阅没有更新。 But below I have this code
但是下面我有这段代码
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)
});
and I get a console log message each time it updates. 并且每次更新时都会收到一条控制台日志消息。
both selectors looks like this: 两个选择器都看起来像这样:
export const selectLoadingState = (state: AppState) => state.structures.isLoading;
any idea on this? 有什么想法吗?
Ok I figured out: 好吧,我想通了:
this.store.select(fromTreeSelector.selectLoadingState),
this.store.select(fromFinanceSelector.selectLoadingState)
I have to add this.store
now it is working. 现在,我必须添加
this.store
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.