0
votes

My problem is simple. I have 2 observables:

assetNodes$: Observable<Asset[]>;
isLoading$: Observable<boolean>;

I am selecting Observables for these 2 using the following code:

this.assetNodes$ = this.store.pipe(select((state: AppState) => state.dashboard.assetTree));
    this.isLoading$ = this.store.pipe(select((state: AppState) =>
    {
      console.log(state)
      state.dashboard.assetTreeLoading
    }));

The variable assetNodes$ works fine, but the second Observable this.isLoading$ is never called (and hence no console.log). I believe this is due to the fact you can only select from the store once? What am I doing wrong here?

1
Do you subscribe to it? - martin
@martin not explicitly no, I use it in my html, e.g. [nbSpinner]="isLoading$ | async" - ViqMontana

1 Answers

1
votes

You can select more than once from the store. I think it's because you aren't returning something in the second selector:

this.isLoading$ = this.store.pipe(select((state: AppState) =>
    {
      console.log(state);
      return state.dashboard.assetTreeLoading;
    }));