Adding NgRx to Your Existing Applications

https://indepth.dev/adding-ngrx-to-your-existing-applications/

Hi Andrew,

Great post, you have a nice introduction to what NgRx is and the various parts of the framework. Have you had to add NgRx to larger real world application? It’ll be interesting to hear what you found out, if you have.

I’m currently working on a few older Angular applications which aren’t using NgRx, and a new one that is. I’d love to convert the older apps to using NgRx, just for the structure it gives the code for one thing (especially as the app has been worked on by serveral different developers who all seem to have different approaches to writing Angular).

Anyway, it’ll be interesting to hear your thoughts on adding NgRx to an existing larger Angular app.

Stephen

1 Like

Hi Stephens,

as always I would say: It depends :wink:

I would ask myself following questions:

  • Is there already a problem with inconsistent view states?
  • Is the code hard to maintain already?
  • Is enough time to do it?

I would only do it if at least two question are answered with YES :slight_smile:

The migration itself should be done step by step, so that we can learn form our mistakes.
From a technical viewpoint I see no problem in doing that.
Of course having tests which guarantees that everything works as expected after the changes would be great as well.

Cheers Christian

2 Likes

Thanks @C-J! Appreciate you providing a response and info.

Hi @StephenAdams,

Thanks for reading my post! I know a lot of of folks are in your situation, especially since many companies are looking at NgRx as a good solution to scale applications.

As Christian has already pointed out, it really depends on the project. One of the biggest things that people run into is wanting to use a newer framework because it’s become popular etc.

I think switching over to NgRx is a great option if you’re prepared to go through the migration process. It should definitely depend on the project and the team you are with. A lot of times you only have budget to work on a project for a limited scope, and don’t have the time to devote to learn a new framework etc. The other issue is that if your team doesn’t have the established skillset then you’ll definitely need to take some time for everyone to learn. This process of building skills could be costly and should definitely be a consideration.

Since you mentioned that your project had been touched by several developers, it might be a great opportunity to refactor the app and get rid of some technical debt. Switching to NgRx might also be a chance to really improve a lot of the flows that your application already has.

Either way, I would definitely suggest giving it a lot of thought before switching. I wouldn’t recommend switching unless you think it would improve your application, and your application is large enough to benefit from the features of NgRx. The example I outlined in my post was purposely small so I could focus on showing how to migrate features etc. NgRx really shows its strength with larger applications that need to scale etc.

I hope this helped, and thanks again for reading my article!

Thanks,
Andrew Evans

Hi Andrew,

Thanks for getting back to me. You’re right, while NgRx has a lot of advantages, it’s not ideal for all projects. So adding it to an existing app requires a lot of consideration.

Stephen