Is it approved to use Redux
with Angular 2
for state management, or does Angular 2 provide some internal mechanism to manage the application state in a consistent way?
Redux is defined as an open-source JavaScript library that works to manage and centralize the state of an application. When combined with Angular and React, it is done with the intention of building user interfaces, similar to Facebook's Flux architecture.
NgRx uses the Redux concept of unidirectional data flow, where all application data goes through the same lifecycle. This unidirectional data flow makes the application's state more predictable and thus easier to understand.
So this means that Redux helps us cope with situations where we are passing inputs to components up the component tree using @Input() , but those inputs feel extraneous, as not part of the application at that point. For example, we are passing something 5 or 10 levels up the component tree.
To use Redux in the Angular framework, we can use the NgRx library. This is a reactive state management library. With NgRx, we can get all events (data) from the Angular app and put them all in the same place (Store).
"Internally" it is not a bundled feature or module. But the guys @NGRX have done an absolutely fantastic job in supporting this pattern in angular2.
Take a look at these following resources for more details: https://github.com/ngrx/store
https://blog.sstorie.com/building-an-angular-2-reactive-auto-logout-timer-with-the-redux-pattern/
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