Search code examples
ngrx

How to decipher ngrx API


Can someone help me to go through this definition step by step? select<T, Props, K>(pathOrMapFn: string | ((state: T, props?: Props) => any), propsOrPath: string | Props, ...paths: string[]) I don't get the hang of it...


Solution

  • It's the definition of the a selector.

    • T: the incoming state
    • Props: if you're calling a selector with props
    • K: the result of the selector

    • pathOrMapFn can either be the path to the state or a createSelector

    • propsOrPath can either be the path to the state or the props
    • ...paths: string[] the rest of the path

    With path to state I mean: select('featureState', 'persons', 'entities')