Giter Club home page Giter Club logo

ngrx-demo's Introduction

Angular Ngrx Demo

In this demo repo, we'll see by examples how to use NgRx with Angular to manage application state.

This project was generated with Angular CLI version 7.0.6

Webpack Bundle Analysis and Statistics

This repository is integrated with packtracker.io, which provids webpack bundle analysis and statistics on every pull request basis and establish performance budgets for your asset profile. To view the webpack bundle analysis and statistics, visit packtracker.io

Table of contents:

  1. Prerequisites and Installation
  2. Quick Start
  3. Demo UI
  4. Build Tasks and Commands
  5. Changelog
  6. References

Prerequisites and Installation

Library Version Notes
Node 10.9.0 Recommended NodeJS version
NPM 6.5.0 Recommended NPM version
Angular ~7.1.x JavaScript-based open-source front-end SPA framework
Angular CLI 7.1.x Set of development tools for Angular
RxJS ~6.3.3 JavaScript library for reactive programming using Observables
@ngrx/store ~7.0.0 Manage reactive state for Angular
@ngrx/effects ~7.0.0 Implement side-effects like http requests, logging, notifications
@ngrx/store-devtools ~7.0.0 Development tool to monitor and debug NGRX actions, state, effects and also enables a powerful time-travelling debugger
@ngrx/entity ~7.0.0 Manage state and CRUD operations for object collection and array
@ngrx/router-store ~7.0.0 Connects the Angular Router to ngrx store to manage state for angular router
ngrx-store-freeze ~0.2.4 Meta-reducer that prevents state from being mutated
angular-in-memory-web-api ~0.8.0 An in-memory web api for Angular demos and tests that emulates CRUD operations over a RESTy API.

Quick Start

To launch the demo application, you can try below steps yourself on your computer, or launch the application on StackBlitz, by clicking here.

  1. Clone repository and checkout the master branch

    git clone https://github.com/kumaran-is/ngrx-demo.git
    cd demos
    git checkout master
    cd ngrx-demo
  2. Install NPM dependencies

    npm install
  3. Run linting and unit test

    ng lint
    ng test
  4. Start application in development mode

    ng serve -o
  5. Application opens in browser http://localhost:4200

Build Tasks and Commands

Code scaffolding

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Demo UI

The goal of this demo application is to show-case on how you can use NgRx in your Angular application to manage application state.

Demo UI screen is organized into 7 pages with separate menus in the top navigation bar. Each screen will show case common usecase by examples as mentioned below.

  1. Demo 1 - To show-case basic usage of NgRx to publish and read state from NgRx Store

  2. Demo 2 - To show-case how to lazy load state for lazy loaded feature modules

  3. Demo 3 - To show-case how to deal with API calls using @ngrx/effects

  4. Demo 4 - To show-case how to implement Search functionality using Angular Reactive Forms with NgRx

  5. Demo 5 - To show-case how to implement Search functionality using @ngrx/entity

  6. Demo 6 - To show-case how to implement CRUD operations using @ngrx/entity

  7. Demo 7 - To show-case how to optimize and encapsulate NgRx coding using Facade pattern

Also added following features to the demo applications at global level:

  1. Implemented meta-reducer to clear store when user logs out.

  2. Implemented meta-reducer to log actions/state events to the browser console for debugging

  3. Added third-party meta-reducer library ngrx-store-freeze@~0.2.4 to prevent state from being mutated

  4. Added util function action-unique.ts to ensure that each action is unique. This prevents any double actions being dispatched.

  5. Added ngrx/router-store to bind router states like route param, route queryParam and route url to store. Also added selectors to query route param, route queryParam and route url from store

  6. Integrated Redux DevTools provided by NGRX library @ngrx/store-devtools to monitor and debug store in non-production environments using Google Chrome Redux DevTools Plugin or Firefox Redux DevTools Extension.

  7. Implemented smart(container) and dump(presentation) component pattern with NgRx to optimize page rendering using Angular OnPush ChangeDetectionStrategy

Changelog

Follow this link for change history

References

ngrx-demo's People

Contributors

kumaran-disney avatar kumaran-is avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.