Skip to content

Commit c55b978

Browse files
committed
Initial commit
0 parents  commit c55b978

34 files changed

+9414
-0
lines changed

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events.json
15+
speed-measure-plugin.json
16+
17+
# IDEs and editors
18+
/.idea
19+
.project
20+
.classpath
21+
.c9/
22+
*.launch
23+
.settings/
24+
*.sublime-workspace
25+
26+
# IDE - VSCode
27+
.vscode/*
28+
!.vscode/settings.json
29+
!.vscode/tasks.json
30+
!.vscode/launch.json
31+
!.vscode/extensions.json
32+
.history/*
33+
34+
# misc
35+
/.sass-cache
36+
/connect.lock
37+
/coverage
38+
/libpeerconnection.log
39+
npm-debug.log
40+
yarn-error.log
41+
testem.log
42+
/typings
43+
44+
# System Files
45+
.DS_Store
46+
Thumbs.db

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# NgrxWorkshopExample
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.8.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
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`.
12+
13+
## Build
14+
15+
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.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

angular.json

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"ngrx-workshop-example": {
7+
"root": "",
8+
"sourceRoot": "src",
9+
"projectType": "application",
10+
"prefix": "ngrx",
11+
"schematics": {
12+
"@schematics/angular:class": {
13+
"skipTests": true
14+
},
15+
"@schematics/angular:component": {
16+
"skipTests": true
17+
},
18+
"@schematics/angular:directive": {
19+
"skipTests": true
20+
},
21+
"@schematics/angular:guard": {
22+
"skipTests": true
23+
},
24+
"@schematics/angular:module": {
25+
"skipTests": true
26+
},
27+
"@schematics/angular:pipe": {
28+
"skipTests": true
29+
},
30+
"@schematics/angular:service": {
31+
"skipTests": true
32+
}
33+
},
34+
"architect": {
35+
"build": {
36+
"builder": "@angular-devkit/build-angular:browser",
37+
"options": {
38+
"outputPath": "dist/ngrx-workshop-example",
39+
"index": "src/index.html",
40+
"main": "src/main.ts",
41+
"polyfills": "src/polyfills.ts",
42+
"tsConfig": "src/tsconfig.app.json",
43+
"assets": [
44+
"src/favicon.ico",
45+
"src/assets"
46+
],
47+
"styles": [
48+
"src/styles.css"
49+
],
50+
"scripts": [],
51+
"es5BrowserSupport": true
52+
},
53+
"configurations": {
54+
"production": {
55+
"fileReplacements": [
56+
{
57+
"replace": "src/environments/environment.ts",
58+
"with": "src/environments/environment.prod.ts"
59+
}
60+
],
61+
"optimization": true,
62+
"outputHashing": "all",
63+
"sourceMap": false,
64+
"extractCss": true,
65+
"namedChunks": false,
66+
"aot": true,
67+
"extractLicenses": true,
68+
"vendorChunk": false,
69+
"buildOptimizer": true,
70+
"budgets": [
71+
{
72+
"type": "initial",
73+
"maximumWarning": "2mb",
74+
"maximumError": "5mb"
75+
}
76+
]
77+
}
78+
}
79+
},
80+
"serve": {
81+
"builder": "@angular-devkit/build-angular:dev-server",
82+
"options": {
83+
"browserTarget": "ngrx-workshop-example:build"
84+
},
85+
"configurations": {
86+
"production": {
87+
"browserTarget": "ngrx-workshop-example:build:production"
88+
}
89+
}
90+
},
91+
"extract-i18n": {
92+
"builder": "@angular-devkit/build-angular:extract-i18n",
93+
"options": {
94+
"browserTarget": "ngrx-workshop-example:build"
95+
}
96+
},
97+
"test": {
98+
"builder": "@angular-devkit/build-angular:karma",
99+
"options": {
100+
"main": "src/test.ts",
101+
"polyfills": "src/polyfills.ts",
102+
"tsConfig": "src/tsconfig.spec.json",
103+
"karmaConfig": "src/karma.conf.js",
104+
"styles": [
105+
"src/styles.css"
106+
],
107+
"scripts": [],
108+
"assets": [
109+
"src/favicon.ico",
110+
"src/assets"
111+
]
112+
}
113+
},
114+
"lint": {
115+
"builder": "@angular-devkit/build-angular:tslint",
116+
"options": {
117+
"tsConfig": [
118+
"src/tsconfig.app.json",
119+
"src/tsconfig.spec.json"
120+
],
121+
"exclude": [
122+
"**/node_modules/**"
123+
]
124+
}
125+
}
126+
}
127+
}
128+
},
129+
"defaultProject": "ngrx-workshop-example"
130+
}

db.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"movies": [
3+
{
4+
"id": "1",
5+
"name": "Interstellar",
6+
"rating": 4.5
7+
},
8+
{
9+
"id": "2",
10+
"name": "Inception",
11+
"rating": 1.0
12+
}
13+
]
14+
}

package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "ngrx-workshop-example",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"test": "jest",
9+
"lint": "ng lint",
10+
"e2e": "ng e2e"
11+
},
12+
"jest": {
13+
"preset": "jest-preset-angular",
14+
"setupFilesAfterEnv": [
15+
"<rootDir>/src/setupJest.ts"
16+
]
17+
},
18+
"private": true,
19+
"dependencies": {
20+
"@angular/animations": "~7.2.0",
21+
"@angular/common": "~7.2.0",
22+
"@angular/compiler": "~7.2.0",
23+
"@angular/core": "~7.2.0",
24+
"@angular/forms": "~7.2.0",
25+
"@angular/platform-browser": "~7.2.0",
26+
"@angular/platform-browser-dynamic": "~7.2.0",
27+
"@angular/router": "~7.2.0",
28+
"@ngrx/effects": "^7.4.0",
29+
"@ngrx/entity": "^7.4.0",
30+
"@ngrx/store": "^7.4.0",
31+
"core-js": "^2.5.4",
32+
"rxjs": "~6.3.3",
33+
"tslib": "^1.9.0",
34+
"uuid": "^3.3.2",
35+
"zone.js": "~0.8.26"
36+
},
37+
"devDependencies": {
38+
"@angular-devkit/build-angular": "~0.13.0",
39+
"@angular/cli": "~7.3.8",
40+
"@angular/compiler-cli": "~7.2.0",
41+
"@angular/language-service": "~7.2.0",
42+
"@types/jest": "^24.0.11",
43+
"@types/node": "~8.9.4",
44+
"@types/uuid": "^3.4.4",
45+
"concurrently": "^4.1.0",
46+
"jasmine-marbles": "^0.4.1",
47+
"jest": "^24.7.1",
48+
"jest-preset-angular": "^7.0.1",
49+
"json-server": "^0.14.2",
50+
"ts-node": "~7.0.0",
51+
"tslint": "~5.11.0",
52+
"typescript": "~3.2.2"
53+
}
54+
}

src/app/app-routing.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
const routes: Routes = [];
5+
6+
@NgModule({
7+
imports: [RouterModule.forRoot(routes)],
8+
exports: [RouterModule]
9+
})
10+
export class AppRoutingModule { }

src/app/app.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Component } from "@angular/core";
2+
3+
@Component({
4+
selector: "ngrx-root",
5+
template: `
6+
<h1>NgRx Workshop Example</h1>
7+
<router-outlet></router-outlet>
8+
`,
9+
styles: []
10+
})
11+
export class AppComponent {}

src/app/app.module.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { BrowserModule } from "@angular/platform-browser";
2+
import { NgModule } from "@angular/core";
3+
4+
import { AppRoutingModule } from "./app-routing.module";
5+
import { AppComponent } from "./app.component";
6+
import { StoreModule } from "@ngrx/store";
7+
import { reducers, metaReducers } from "./shared/state";
8+
import { EffectsModule } from "@ngrx/effects";
9+
import { MoviesModule } from "./movies/movies.module";
10+
11+
@NgModule({
12+
declarations: [AppComponent],
13+
imports: [
14+
BrowserModule,
15+
AppRoutingModule,
16+
StoreModule.forRoot(reducers, { metaReducers }),
17+
EffectsModule.forRoot([]),
18+
MoviesModule
19+
],
20+
providers: [],
21+
bootstrap: [AppComponent]
22+
})
23+
export class AppModule {}

src/app/movies/actions/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as MovieApiActions from "./movie-api.actions";
2+
import * as MoviePageActions from "./movie-page.actions";
3+
4+
export { MovieApiActions, MoviePageActions };
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { createAction, props } from "@ngrx/store";
2+
import { Movie } from "src/app/shared/models/movie.model";
3+
4+
export const loadMoviesSuccess = createAction(
5+
"[Movie API] Load Movies Success",
6+
props<{ movies: Movie[] }>()
7+
);
8+
9+
export const loadMoviesFailure = createAction(
10+
"[Movie API] Load Movies Failure"
11+
);
12+
13+
export const createMovieSuccess = createAction(
14+
"[Movie API] Create Movie Success",
15+
props<{ movie: Movie }>()
16+
);
17+
18+
export const createMovieFailure = createAction(
19+
"[Movie API] Create Movie Failure"
20+
);
21+
22+
export const updateMovieSuccess = createAction(
23+
"[Movie API] Update Movie Success",
24+
props<{ movie: Movie }>()
25+
);
26+
27+
export const updateMovieFailure = createAction(
28+
"[Movie API] Update Movie Failure",
29+
props<{ movie: Movie }>()
30+
);
31+
32+
export const deleteMovieSuccess = createAction(
33+
"[Movie API] Delete Movie Success",
34+
props<{ movieId: string }>()
35+
);
36+
37+
export const deleteMovieFailure = createAction(
38+
"[Movie API] Delete Movie Failure",
39+
props<{ movie: Movie }>()
40+
);
41+
42+
export type Union = ReturnType<
43+
| typeof loadMoviesSuccess
44+
| typeof loadMoviesFailure
45+
| typeof createMovieSuccess
46+
| typeof createMovieFailure
47+
| typeof updateMovieSuccess
48+
| typeof updateMovieFailure
49+
| typeof deleteMovieSuccess
50+
| typeof deleteMovieFailure
51+
>;

0 commit comments

Comments
 (0)