NgRx Code Review Checklist

by | Jan 21, 2019

NgRx (Reactive Extensions for Angular) is becoming more and more popular in the Angular community.  It is a great way to manage state using the redux pattern and keep your application scalable.  In this blog post, we provide a checklist for efficiently and expertly reviewing NgRx code, with links to our NgRx tutorial series for additional instruction.

 

8- Step NgRx Code Review Checklist

 

  • Is the code in the correct location in the folder structure?
    Your organization should agree upon standards for where to put store-related code.  I personally believe it should be under a “store” folder at the main level and for each feature module.  Much easier to find code in this structure.  See a picture of a good folder structure near the bottom of this post:  https://www.intertech.com/ngrx-tutorial-actions-reducers-and-effects
  • For the feature module State interface, does it extend the main State interface?
    Feature modules reducers need to define a State interface that extends the main State interface so that the feature module has access to its own State and the main State. It’s broken down in this post:  https://www.intertech.com/ngrx-tutorial-add-state-to-feature-module
  • Are you retrieving parameters from the URL using NgRx?
    It is very important to have one source of truth with NgRx and programming in general. If you are storing things like customerId in the store but it’s always available in the URL, you’re doing it wrong.  Find the details here: https://www.intertech.com/ngrx-tutorial-add-router-info-to-state/
  • Are you loading and updating the store from the API using effects?
    It can be tempting just to call a service on the component and dispatch the results to store the data in NgRx but this is the wrong approach. It’s best to use an effect to call the API and store the resulting data in State via another action that the reducer handles.  The effect is called via a store dispatch of an action that the effect is listening for.  For details, check this post: https://www.intertech.com/ngrx-tutorial-actions-reducers-and-effects/

About Intertech

Founded in 1991, Intertech delivers software development consulting to small, medium and large companies, including Fortune 500 companies, as well as Government and Leading Technology institutions. Learn more about us. Whether you are a developer interested in working for a company that invests in its employees or a company looking to partner with a team of technology leaders who provide solutions, mentor staff and add true business value, we’d like to meet you.