Search code examples
angulartypescriptrxjsstore

Select store inside store from the appState


I have a store like this

    {
      rootStore: {
        firstStore: {
          el: false,
          sec: false,
          th: []
        }
      }
    }

how can i get the first store in one go (using one select statement), now I use

() => (state: Observable<any>) => state.select('rootStore').select('firstStore');

Solution

  • You would have to use map:

    () => (state: Observable<any>) => state.map(store => store.rootStore.firstStore);
    

    As an alternative, since select is basically an alias for pluck this works as well:

    () => (state: Observable<any>) => state.select('rootStore', 'firstStore');