I have been exploring ngrx (ngrx/store) lately. I have studied some classic examples on the net (a todo app). Great example. Now I am want to take it to the next level by letting my ngrx app do some API calls. Are there examples or guidelines how to setup a ngrx (redux) app to invoke and handle api calls?
It's my understanding that api calls within the context of my redux app are side-effects (functional programming paradigm). I am wondering how/where to implement API calls in a redux app.
When should you not use NgRx? Never use NgRx if your application is a small one with just a couple of domains or if you want to deliver something quickly. It comes with a lot of boilerplate code, so in some scenarios it will make your coding more difficult.
Ngrx is a group of Angular libraries for reactive extensions. Ngrx/Store implements the Redux pattern using the well-known RxJS observables of Angular 2. It provides several advantages by simplifying your application state to plain objects, enforcing unidirectional data flow, and more.
NgRx, which is the Angular version of Redux for React is for State Management. In React, state management can get complicated, and Redux is there to help. For Angular, this should not be the case as everything is synced due to two way data binding.
Luckily, NgRx provides state and action sanitizers that can be used to clean up your data to reduce the amount of state (for example, multiple arrays with thousands of items) to improve the performance of the devtool.
Ngrx has its own library for side-effects ngrx/effects Some more information:
There are not much resource about this library. You can find more here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With