javascript - mixLatest 与 ngrx 不更新更改

标签 javascript angular 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 现在它正在工作。

关于javascript - mixLatest 与 ngrx 不更新更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50348685/

相关文章:

javascript - 如何在 ngMap 中将谷歌地图设置为 100% 高度

angular - 结合 Angular 和纹理

javascript - 无法在 p-autocomplete 中将值绑定(bind)到 ngModel

javascript - Angular ngrx 属性 'payload' 在类型 'Action' 上不存在

angular - NGRX 和嵌套关系示例

javascript - AJAX 请求无法被 PHP 脚本识别为 POST

javascript - 如何转换特定时区的日期并发送到服务器

javascript - 自然语言处理数据库查询

angular - 为什么@ContentChildren 在查询匹配的选择器时包含 self(this)?

angular - Observable.subscribe() 只工作一次 (ngrx\angular2)