Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redux and Angular 2

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?

like image 681
Tuomas Toivonen Avatar asked Jun 10 '16 15:06

Tuomas Toivonen


People also ask

Can I use Redux with Angular?

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.

Is NgRx same as Redux?

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.

Why would you use Redux in an Angular project?

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.

How do I add Redux to Angular app?

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).


1 Answers

"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/

like image 112
Nige Avatar answered Oct 07 '22 01:10

Nige