Skip to main content


Showing posts with the label NgRx

NgRx(Version 12) | An Angular State Management Using @ngrx/data

In this article, we are going to implement an Angular application state management using @ngrx/data. @ngrx/data: In a general angular application using NgRx Store, Effects, and Entity libraries made us to write a huge number of actions, reducers, effects, selectors, HTTP API calls per entity model. It leads to a lot of repetitive code to create, maintain and test. Using NgRx Data we can reduce our code to very little despite having a large number of entity models in our application. The NgRx Data is an abstraction over the Store, Effects, and Entity that radically reduces the amount of code we have to write. By gaining the abstraction benefit, we are going to lose our direct interaction with NgRx libraries. Ngrx Store Flow: Using Ngrx we never contact the store directly, every store operation is carried out by the NgRx store implicitly. Our main point of contact is EntityCollectionService. Using EntityCollectionService for each entity can invoke API calls with default method like '

NgRx(Version 12) - An Angular Application State Management Using @ngrx/store

In this article, we will implement a sample Angular(Version 12) application state management using @ngrx/store(NgRx Version 12). NgRx Store For State Management: NgRx Store provides state management for creating maintainable, explicit applications through the use of a single state and actions in order to express state changes. The main building blocks for the NgRx store are: Actions Reducers Selectors NgRx Store State Management Flow: Angular components trigger the API call and fetch the response data. Angular component raises events through actions. Component passes the API response to the Actions. Reducers are logical functions that listen for action changes. Reducers update the store state based on actions and the payload carried by the actions. Selectors are consumed by angular components. Selectors serve the data from the store to angular components. Create An Angular Application: To start our demo let's create a sample angular application. Install Angular CLI: npm instal

Angular State Management With NgRx

Introduction: NgRx framework helps Angular to develop more reactive applications. NgRx provides state management to an application, where data of an application is stored at a single place and then supplied throughout the application where ever needed. Using NgRx if data is updated, all the components consuming that data get updated instantly. Benefits of using NgRx with Angular application like Serializability, Type Safety, Encapsulation, Testable, and Performance. Key Features: NgRx framework key features like Store: A  s tore is a data place where all the application related information stored and supplied to the Angular components on demand. Reducer: A reducer is a pure function based on Actions it returns the new state. Actions: An action expresses an event of an application, that causes a change in the state of the application. Selector: A selector is a pure function that obtains a slice of data from the store. Effects: An Effect is to isolate components f