Ionic5, NgRX & Capacitor

Is anyone using Ionic5 combined with NgRX & Capacitor? I am currently asking myself, if I should use NgRX to handle that state management. Any feedback available?

Hi
I reckon there is lots to find on the web about Angular and State management, including pros and cons of various solutions out there. Not sure if adding Capacitor or Ionic5 adds to the complexity of your thinking process.

Are you expecting any complications in the combination with Ionic and Capacitor?

I guess it is a matter of how you developer flow looks like and future of the app - it is said that if your app is complex and you have many developers, NGRX (or something similar) can be better. Some say NGRX is too complex and there easier alternatives, including using good ol’ BehaviorSubject in own version.

My 2cts

Regards

Tom

1 Like

Yes I have combined them. IMO, They work great but if i would go back and change it, it would be to use RxJS instead. NGRX should be used in large enterprise projects.

NGRX adds an extra layer of complexity and LOTS of boilerplate to your project and would be a nightmare to figure out bugs if not done correctly.

There are several alternatives to NGRX: NGSX, Akita, RxJS. Several have their own things. But its good to mention that since Angular it self is using RxJs, might as well use it so you don’t have to install another package and add more complexity. Hope this helps.

2 Likes

Echo what @mikrochipkid is saying. Even though ngrx has API with a bit less boilerplate (entity adapter), trying to be a bit more accessible. To me the downside is I like to have a service as wrapper for CRUD calls, instead of components knowing how to dispatch actions. And that creates even more code

1 Like

That is a fair point. I was unsure why RxJS shouldn’t be good enough, since I’m able to subscribe to changes anyway. I am building a microservice driven backend based on Nest, RabbitMQ & PostgreSQL and Ionic5 & Capacitor on the Frontend (IOS/Android/Web). I will just use RxJS since it is way easier to implement and changes will pushed to the API anyway.

Thanks,
Oliver

2 Likes

I can say after implementing different projects that NgRx is too complex, but it avoids circular references and a lot of mess up in big or complex projects. Then I learned to use the best of NgRx only when needed, Subjects and RxJx for other things.

Now I am satisfied with the balance of two worlds.

Kind Regards,
Jocafi

I personally prefer akita state management with angular / ionic,
build on rxjs and scales perfect from small to large apps

1 Like