What is the best structure for app using ngrx?

前端 未结 2 873
伪装坚强ぢ
伪装坚强ぢ 2021-02-12 15:24

Structure 1

reducers
   index.ts //Combine all reducers
   user.reducer.ts
   product.reducer.ts
actions
   index.ts  //Combine all actions
   user.action.ts
            


        
2条回答
  •  灰色年华
    2021-02-12 15:35

    I follow this guide for best ngRx practices and structure:

    https://github.com/orizens/ngrx-styleguide

    The second way you mentioned is the best because (quoting from the style guide):

    DO create separated files in the reducer's directory for: reducer, reducer's spec, reducer's actions and reducer's selectors. Finally, use index.ts as a barrel for exporting each file's content. Why? it's easier when developing to locate each relevant class/file

提交回复
热议问题