Angular-ngrx Demo
What is this
Write less code for managing the ngrx redux pattern for multiple entity models in an app.
Why use it
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
How
TODO: Explain how to implement this in a new Angular CLI app
Requirements
-
Install the Angular CLI
npm install -g @angular/cli
-
Create a CosmosDB instance
Getting Started
-
Clone this repository
git clone https://github.com/johnpapa/angular-ngrx.git cd angular-ngrx
-
Install the npm packages
npm i
Running the app
-
Build the Angular app and launch the node server
npm run build npm run dev
-
Open the browser to http://localhost:3001
Docker
- Install and run Docker
Environment file
Create an empty file named .env
in the root of the app. We'll fill this in later.
Docker Compose with Debugging
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
Optional Database
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