gpt4 book ai didi

javascript - mixLatest 与 ngrx 不更新更改

转载 作者:行者123 更新时间:2023-12-03 01:52:42 24 4
gpt4 key购买 nike

我有以下代码:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com