Write less code for managing the ngrx redux pattern for multiple entity models in an app.
Managing state can be challenging. The Redux pattern that ngrx implements helps manage state in Angular apps by adding reducers, actions, states, effects, dispatchers, and selectors. This library aims to demonstrate a technique that will reduce the boilerplate to implement ngrx.
TODO: Link to FAQ
TODO: Explain how to implement this in a new Angular CLI app
-
Install the Angular CLI
npm install -g @angular/cli
-
Create a CosmosDB instance
-
Clone this repository
git clone https://github.com/johnpapa/angular-ngrx.git cd angular-ngrx
-
Install the npm packages
npm i
-
Build the Angular app and launch the node server
npm run build npm run dev
-
Open the browser to http://localhost:3001
- Install and run Docker
Create an empty file named .env
in the root of the app. We'll fill this in later.
Create the Docker image and run it locally. This commands uses docker-compose
to build the image
and run the container.
This opens port 9229
for debugging.
npm run docker-debug
open http://localhost:3001
Open VS Code, launch the Docker: Attach to Node
debugging profile
NODE_ENV=development
PORT=3001
PUBLICWEB=./publicweb
COSMOSDB_ACCOUNT=your_cosmos_account
COSMOSDB_DB=your_cosmos_db
COSMOSDB_KEY=your_cosmos_key
COSMOSDB_PORT=10255
Out of the box you can run the demo with an in memory data service instead of a live database. If you wish to use a database, you can set up a local mongo server or a remote CosmosDB/MongoDB server in the cloud.
-
Configure Cosmos DB server settings
Copy the contents from
.env.example
into.env
. Replace the values with your specific configuration. Don't worry, this file is in the.gitignore
so it won't get pushed to github.NODE_ENV=development PORT=3001 PUBLICWEB=./publicweb COSMOSDB_ACCOUNT=your_cosmos_account COSMOSDB_DB=your_cosmos_db COSMOSDB_KEY=your_cosmos_key COSMOSDB_PORT=10255