zoukankan      html  css  js  c++  java
  • [NGXS] Selector

    When defining a selector, you can also pass other selectors into the signature of the Selector decorator to join other selectors with this state selector.

    @State<PreferencesStateModel>({ ... })
    export class PreferencesState { ... }
    
    @State<string[]>({ ... })
    export class ZooState {
    
     @Selector([ZooState, PreferencesState])
     static firstLocalPanda(state: string[], preferencesState: PreferencesStateModel) {
       return state.find(
         s => s.indexOf('panda') > -1 && s.indexOf(preferencesState.location)
       );
     }
    
     @Selector([ZooState.firstLocalPanda])
     static happyLocalPanda(panda: string) {
       return 'happy ' + panda;
     }
    
    }

    Now the happyLocalPanda will only recalculate when the output value of the firstLocalPanda selector changes.

    We recommend that you move your projects to this behavior in order to optimize your selectors and to prepare for the change to the defaults coming in NGXS v4. See the Selector Options section above for the recommended settings.

  • 相关阅读:
    <庆余年>
    JUC-12.3-线程的调度
    JUC-12.1-线程池介绍
    JUC-12.2-线程池使用
    JUC-11-线程八锁
    JUC-10-ReadWriteLock读写锁
    JUC-9-线程按序交替
    JUC-8-lock和Condition使用
    JUC-7-lock接口
    xcode单词及回调
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12202708.html
Copyright © 2011-2022 走看看