NgRx Interview Questions
In this post we will look at NgRx Interview questions. Examples are provided with explanation.
Q: What is NgRx?
A: NgRx is a framework for building reactive applications in Angular. NgRx provides state management, isolation of side effects, entity collection management, router bindings, code generation, and developer tools that enhance developers experience when building many different types of applications.
Q: What are benefits of using store (ngrx) in angular 2 ?
- Centralized, Immutable State - All relevant application state exists in one location. This makes it easier to track down problems, as a snapshot of state at the time of an error can provide important insight and make it easy to recreate issues.
- Performance - Since state is centralized at the top of your application, data updates can flow down through your components relying on slices of store.
- Testability -All state updates are handled in reducers, which are pure functions. Pure functions are extremely simple to test, as it is simply input in, assert against output.
Q: What are Reducers in NgRX?
A: Reducers in NgRx are responsible for handling transitions from one state to the next state in your application. Reducer functions handle these transitions by determining which actions to handle based on the action's type. Reducers are pure functions that are the only ones that can change state. They are not really changing state but making a copy of existing state and changing one or more properties on the new state.
Q: What is the difference between NgRX and RxJS?
A: Ngrx is a redux implementation usingrxjs. Rxjs is for handling complex asynchronous work like handling communication between client and server. Ngrx is for optimally storing data in the client and recalling them from all over the application, usually.