javascript - combineLatest 与 ngrx 未更新更改
问题描述
我有以下代码:
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
现在它正在工作。
推荐阅读
- dataweave - 如果元素存在,则使用 Dataweave 将键添加到数组
- ruby-on-rails - 如何在表单中为 HMABTM 关系 Rails 添加多条记录
- excel - 如果不满足条件,如何使用 SUMIF 生成空白
- google-developer-tools - 如何在没有 TFA 的情况下重新获得对 Google Developer 帐户的访问权限?
- css - 纯 CSS - 使用 mask-image 和 Radial-gradient 制作菱形形状
- excel - How to remove multiple characters in a string in excel
- c - Programming with C macros
- c# - How to get parameters from stored procedures in a textbox in C # occupying ODBC?
- c# - .NET Web API Blueimp multiple file upload error "Unexpected end of MIME multipart stream. MIME multipart message is not complete."
- python - Tkinter PhotoImage in function doesn't appear