【问题标题】:Select store inside store from the appState从 appState 中选择 store inside store
【发布时间】:2017-05-14 16:15:30
【问题描述】:

我有这样的商店

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

如何一次性获得第一家商店(使用一个 select 语句),现在我使用

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

【问题讨论】:

    标签: angular typescript rxjs store


    【解决方案1】:

    你必须使用map:

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

    作为替代方案,由于 select 基本上是 pluck 的别名,因此也可以:

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

    【讨论】:

    • 酷,第二个也可以,谢谢,这是我要找的
    猜你喜欢
    • 2021-04-24
    • 2021-01-08
    • 2019-01-06
    • 1970-01-01
    • 2022-12-02
    • 2022-12-26
    • 2018-04-10
    • 1970-01-01
    • 2020-09-24
    相关资源
    最近更新 更多