@tech4good/angular-schematics 13.3.0 → 13.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +1 -1
  2. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +2 -4
  3. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +1 -1
  4. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +2 -4
  5. package/src/init/files/{.eslintrc.json → .eslintrc.json.template} +0 -0
  6. package/src/init/files/{.gitattributes → .gitattributes.template} +0 -0
  7. package/src/init/files/.gitignore.template +55 -0
  8. package/src/init/files/angular.json.template +1 -1
  9. package/src/init/files/package.json.template +1 -1
  10. package/src/init/files/src/app/app-routing.module.ts.template +19 -0
  11. package/src/init/files/src/app/{app.component.html → app.component.html.template} +0 -0
  12. package/src/init/files/src/app/{app.component.scss → app.component.scss.template} +0 -0
  13. package/src/init/files/src/app/app.component.ts.template +41 -0
  14. package/src/init/files/src/app/app.module.ts.template +34 -0
  15. package/src/init/files/src/app/core/analytics/log.service.ts.template +35 -0
  16. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +223 -0
  17. package/src/init/files/src/app/core/core.module.ts.template +71 -0
  18. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +284 -0
  19. package/src/init/files/src/app/core/router/routing-state.service.ts.template +28 -0
  20. package/src/init/files/src/app/core/setup/firebase-setup.ts.template +25 -0
  21. package/src/init/files/src/app/core/setup/module-import-guard.ts.template +5 -0
  22. package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +24 -0
  23. package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +41 -0
  24. package/src/init/files/src/app/core/store/app.actions.ts.template +92 -0
  25. package/src/init/files/src/app/core/store/app.effects.ts.template +167 -0
  26. package/src/init/files/src/app/core/store/app.reducer.ts.template +30 -0
  27. package/src/init/files/src/app/core/store/app.selectors.ts.template +30 -0
  28. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +75 -0
  29. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +164 -0
  30. package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +13 -0
  31. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +26 -0
  32. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +21 -0
  33. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +404 -0
  34. package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +376 -0
  35. package/src/init/files/src/app/core/store/effects.helpers.ts.template +66 -0
  36. package/src/init/files/src/app/core/store/user/user.actions.ts.template +269 -0
  37. package/src/init/files/src/app/core/store/user/user.effects.ts.template +131 -0
  38. package/src/init/files/src/app/core/store/user/user.model.ts.template +15 -0
  39. package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +13 -0
  40. package/src/init/files/src/app/core/store/user/user.reducer.ts.template +50 -0
  41. package/src/init/files/src/app/core/store/user/user.service.ts.template +50 -0
  42. package/src/init/files/src/app/core/utils/string-case.utils.ts.template +96 -0
  43. package/src/init/files/src/app/general/e404/{e404.component.html → e404.component.html.template} +0 -0
  44. package/src/init/files/src/app/general/e404/{e404.component.scss → e404.component.scss.template} +0 -0
  45. package/src/init/files/src/app/general/e404/e404.component.spec.ts.template +25 -0
  46. package/src/init/files/src/app/general/e404/e404.component.ts.template +28 -0
  47. package/src/init/files/src/app/general/general-routing.module.ts.template +21 -0
  48. package/src/init/files/src/app/general/general.module.spec.ts.template +13 -0
  49. package/src/init/files/src/app/general/general.module.ts.template +30 -0
  50. package/src/init/files/src/app/general/login/{login.component.html → login.component.html.template} +0 -0
  51. package/src/init/files/src/app/general/login/{login.component.scss → login.component.scss.template} +0 -0
  52. package/src/init/files/src/app/general/login/login.component.spec.ts.template +25 -0
  53. package/src/init/files/src/app/general/login/login.component.ts.template +72 -0
  54. package/src/init/files/src/app/shared/shared.module.ts.template +81 -0
  55. package/src/init/files/src/environments/environment.prod.ts.template +5 -0
  56. package/src/init/files/src/environments/environment.ts.template +18 -0
  57. package/src/init/files/src/styles/{_variables.scss → _variables.scss.template} +0 -0
  58. package/src/init/files/src/{styles.scss → styles.scss.template} +0 -0
  59. package/src/init/files/tsconfig.json.template +31 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tech4good/angular-schematics",
3
- "version": "13.3.0",
3
+ "version": "13.5.0",
4
4
  "description": "A set of schematics for generating modules, containers, components, and entities",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
@@ -10,16 +10,14 @@ export class LoadData implements Action {
10
10
  readonly type = <%= classify(name) %>ActionTypes.LOAD_DATA;
11
11
 
12
12
  constructor(public payload: {
13
- containerId: string,
14
- }) { }
13
+ }, public correlationId: string) { }
15
14
  }
16
15
 
17
16
  /** Action for cleaning up loading subscriptions. */
18
17
  export class Cleanup implements Action {
19
18
  readonly type = <%= classify(name) %>ActionTypes.CLEANUP;
20
19
  constructor(public payload: {
21
- containerId: string,
22
- }) { }
20
+ }, public correlationId: string) { }
23
21
  }
24
22
 
25
23
  export type <%= classify(name) %>Actions =
@@ -21,7 +21,7 @@ export class <%= classify(name) %>Effects {
21
21
  () => this.actions$.pipe(
22
22
  ofType<LoadData>(<%= classify(name) %>ActionTypes.LOAD_DATA),
23
23
  mergeMap((action: LoadData) => {
24
- const loadId = action.payload.containerId;
24
+ const loadId = action.correlationId;
25
25
 
26
26
  return [
27
27
  ];
@@ -63,8 +63,7 @@ export class <%= classify(name) %>Component implements OnInit, OnDestroy {
63
63
 
64
64
  // Once everything is set up, load the data for the role.
65
65
  this.store.dispatch( new LoadData({
66
- containerId: this.containerId,
67
- }) );
66
+ }, this.containerId) );
68
67
  }
69
68
 
70
69
  ngOnDestroy() {
@@ -74,8 +73,7 @@ export class <%= classify(name) %>Component implements OnInit, OnDestroy {
74
73
 
75
74
  // Unsubscribe from firebase connection from load and free up memoized selector values.
76
75
  this.store.dispatch( new Cleanup({
77
- containerId: this.containerId,
78
- }) );
76
+ }, this.containerId) );
79
77
  this.selectors.cleanup(this.containerId);
80
78
  }
81
79
  }
@@ -0,0 +1,55 @@
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
+ .cache
36
+ /.sass-cache
37
+ /connect.lock
38
+ /coverage
39
+ /libpeerconnection.log
40
+ npm-debug.log
41
+ yarn-error.log
42
+ testem.log
43
+ /typings
44
+ *.swp
45
+ .angular
46
+ .cache
47
+
48
+ # System Files
49
+ .DS_Store
50
+ Thumbs.db
51
+
52
+ # Firebase
53
+ .firebase
54
+ *-debug.log
55
+ .runtimeconfig.json
@@ -16,7 +16,7 @@
16
16
  "schematics": {
17
17
  "@schematics/angular:component": {
18
18
  "style": "scss"
19
- },
19
+ }
20
20
  },
21
21
  "root": "",
22
22
  "sourceRoot": "src",
@@ -28,7 +28,7 @@
28
28
  "@ngrx/router-store": "^13.1.0",
29
29
  "@ngrx/store": "^13.1.0",
30
30
  "@ngrx/store-devtools": "^13.1.0",
31
- "@tech4good/angular-schematics": "^13.1.0",
31
+ "@tech4good/angular-schematics": "^13.5.0",
32
32
  "rxjs": "~7.5.0",
33
33
  "tslib": "^2.3.0",
34
34
  "zone.js": "~0.11.4"
@@ -0,0 +1,19 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { Routes, RouterModule } from '@angular/router';
3
+
4
+ // Containers
5
+ import { LoginComponent } from './general/login/login.component';
6
+
7
+ const appRoutes: Routes = [
8
+ // Replace when a default route is set up
9
+ { path: '', redirectTo: 'login', pathMatch: 'full' },
10
+ { path: '**', redirectTo: '404', pathMatch: 'full' },
11
+ ];
12
+
13
+ @NgModule({
14
+ imports: [
15
+ RouterModule.forRoot(appRoutes, { useHash: true }),
16
+ ],
17
+ exports: [RouterModule],
18
+ })
19
+ export class AppRoutingModule { }
@@ -0,0 +1,41 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import { Router, NavigationEnd } from '@angular/router';
3
+ import { select, Store } from '@ngrx/store';
4
+ import * as fromStore from './core/store/app.reducer';
5
+ import { LoadAuth } from './core/store/auth/auth.actions';
6
+ import { RoutingStateService } from './core/router/routing-state.service';
7
+ import { TimeAnalyticsService } from './core/analytics/time-analytics.service';
8
+
9
+ @Component({
10
+ selector: 'app-root',
11
+ templateUrl: './app.component.html',
12
+ styleUrls: ['./app.component.scss'],
13
+ })
14
+ export class AppComponent implements OnInit {
15
+ constructor(
16
+ private router: Router,
17
+ private routingState: RoutingStateService,
18
+ private store: Store<fromStore.State>,
19
+ private analytics: TimeAnalyticsService,
20
+ ) {
21
+ }
22
+
23
+ ngOnInit() {
24
+ // Load auth into store
25
+ this.store.dispatch( new LoadAuth() );
26
+
27
+ // Setup time analytics
28
+ this.analytics.startTimeLogging();
29
+
30
+ // Setup RoutingState to enable retrieving the previous Url
31
+ this.routingState.loadRouting();
32
+
33
+ // Make it so navigating to a new route scrolls back
34
+ this.router.events.subscribe((evt) => {
35
+ if (!(evt instanceof NavigationEnd)) {
36
+ return;
37
+ }
38
+ document.getElementsByClassName('content-container')[0].scrollTop = 0;
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,34 @@
1
+ import { BrowserModule } from '@angular/platform-browser';
2
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3
+ import { NgModule } from '@angular/core';
4
+
5
+ import { AppComponent } from './app.component';
6
+ import { AppRoutingModule } from './app-routing.module';
7
+
8
+ // General Modules
9
+ import { CoreModule } from './core/core.module';
10
+ import { SharedModule } from './shared/shared.module';
11
+
12
+ // Feature Modules
13
+ import { GeneralModule } from './general/general.module';
14
+
15
+ @NgModule({
16
+ declarations: [
17
+ AppComponent,
18
+ ],
19
+ imports: [
20
+ BrowserModule,
21
+ BrowserAnimationsModule,
22
+ CoreModule,
23
+ SharedModule,
24
+ // Feature Modules
25
+ GeneralModule,
26
+ // Routing Module
27
+ AppRoutingModule,
28
+ ],
29
+ providers: [],
30
+ bootstrap: [
31
+ AppComponent,
32
+ ],
33
+ })
34
+ export class AppModule { }
@@ -0,0 +1,35 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { LoggingAngularFirestore } from '../setup/firebase-setup';
3
+ import { isDevMode } from '@angular/core';
4
+
5
+ interface LogData {
6
+ __userId: string;
7
+ route: string;
8
+ startTime: number;
9
+ time: Array<{
10
+ total: number;
11
+ type: string;
12
+ }>;
13
+ interactions?: Array<{ 0: number; 1: string; 2: string; 3: string; }>;
14
+ }
15
+
16
+ @Injectable({
17
+ providedIn: 'root',
18
+ })
19
+ export class LogService {
20
+ /** Whether should log to the console in dev. */
21
+ LOG_IN_DEV = true;
22
+
23
+ constructor(
24
+ private log: LoggingAngularFirestore,
25
+ ) {
26
+ }
27
+
28
+ rawLog(data: LogData, logType: string = 'logs') {
29
+ if (!isDevMode()) {
30
+ this.log.collection(`/${logType}`).add(data);
31
+ } else if (this.LOG_IN_DEV) {
32
+ console.log(data);
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,223 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Router, NavigationEnd } from '@angular/router';
3
+ import { Subject, Observable, ConnectableObservable, fromEvent, merge, combineLatest } from 'rxjs';
4
+ import { startWith, withLatestFrom, tap, takeUntil, switchMap, mergeMap, publishReplay, filter, map, pairwise, scan } from 'rxjs/operators';
5
+ import { FirebaseService } from '../firebase/firebase.service';
6
+ import { LogService } from './log.service';
7
+
8
+ export interface TimeAtRoute {
9
+ route: string;
10
+ startTime: number;
11
+ time: Array<{ type: string, total: number }>;
12
+ }
13
+
14
+ export interface InteractionsAtRoute {
15
+ route: string;
16
+ // We use this typing since Firebase doesn't accept nested arrays
17
+ interactions: Array<{ 0: number, 1: string, 2: string, 3: string }>;
18
+ }
19
+
20
+ @Injectable({
21
+ providedIn: 'root',
22
+ })
23
+ export class TimeAnalyticsService {
24
+ /** Timestamps for all the main user events. */
25
+ private eventTimestamps$: Observable<number>;
26
+
27
+ /** The current route a user is visiting. */
28
+ private currentRoute$: ConnectableObservable<string>;
29
+
30
+ /** The running update of time analytics for each route. */
31
+ private runningTimeAtRoute$: Observable<TimeAtRoute>;
32
+
33
+ /** Only the final time analytics for each route (after navigating to next). */
34
+ private timeAtRoute$: Observable<TimeAtRoute>;
35
+
36
+ /** Events representing different registered interactions. */
37
+ private interactions$: Subject<string> = new Subject<string>();
38
+
39
+ /** Current interactionsAtRoute data. */
40
+ private interactionsAtRoute: InteractionsAtRoute;
41
+
42
+ /** Function that is called by the app to start analytics. */
43
+ public startTimeLogging() {
44
+ // Start logging time
45
+ this.timeAtRoute$.pipe(
46
+ withLatestFrom(this.db.afUser()),
47
+ ).subscribe(([timeAtRoute, user]: [TimeAtRoute, { uid: string }]) => {
48
+ if (user && user.uid) {
49
+ if (!this.interactionsAtRoute || !this.interactionsAtRoute.interactions) {
50
+ this.log.rawLog({
51
+ __userId: user.uid,
52
+ ...timeAtRoute,
53
+ });
54
+ } else if (timeAtRoute.route === this.interactionsAtRoute.route) {
55
+ this.log.rawLog({
56
+ __userId: user.uid,
57
+ ...timeAtRoute,
58
+ interactions: this.interactionsAtRoute.interactions,
59
+ });
60
+ } else {
61
+ console.log('ERROR in time-analytics. Why does route not match?');
62
+ }
63
+ }
64
+ });
65
+
66
+ this.currentRoute$.pipe(
67
+ startWith(null as string),
68
+ pairwise(),
69
+ ).subscribe(([route1, route2]) => {
70
+ if (!route1 || route1 !== route2) {
71
+ this.interactionsAtRoute = { route: route2, interactions: null };
72
+ }
73
+ });
74
+ }
75
+
76
+ /** Function that can be called by a container to register interactions. */
77
+ public registerInteractions(
78
+ interactions: Array<{ 0: string, 1: string, 2: Observable<any> }>,
79
+ unsubscribe$: Subject<void>,
80
+ ) {
81
+ for (const ix of interactions) {
82
+ // Subscribe to each interaction until unsubscribe, and register that the event occured
83
+ ix[2].pipe(
84
+ takeUntil(unsubscribe$),
85
+ ).subscribe((data) => {
86
+ let ixLog = { 0: null, 1: null, 2: null, 3: null };
87
+ if (typeof data === 'string' || typeof data === 'number' || typeof data === 'boolean') {
88
+ ixLog = { 0: Date.now(), 1: String(ix[0]), 2: String(ix[1]), 3: String(data) };
89
+ } else {
90
+ ixLog = { 0: Date.now(), 1: String(ix[0]), 2: String(ix[1]), 3: null };
91
+ }
92
+ if (!this.interactionsAtRoute || !this.interactionsAtRoute.interactions) {
93
+ const newInteractions: Array<{ 0: number, 1: string, 2: string, 3: string }> = [ixLog];
94
+ this.interactionsAtRoute.interactions = newInteractions;
95
+ } else {
96
+ this.interactionsAtRoute.interactions.push(ixLog);
97
+ }
98
+ });
99
+ }
100
+ }
101
+
102
+ constructor(
103
+ private router: Router,
104
+ private db: FirebaseService,
105
+ private log: LogService,
106
+ ) {
107
+ /** Event timestamps from the user. */
108
+ this.eventTimestamps$ = merge(
109
+ fromEvent(document, 'mousemove'),
110
+ fromEvent(document, 'mousedown'),
111
+ fromEvent(document, 'keypress'),
112
+ fromEvent(document, 'click'),
113
+ fromEvent(document, 'scroll'),
114
+ fromEvent(document, 'DOMMouseScroll'),
115
+ fromEvent(document, 'mousewheel'),
116
+ fromEvent(document, 'touchmove'),
117
+ fromEvent(document, 'MSPointerMove'),
118
+ ).pipe(
119
+ map(() => Date.now()),
120
+ );
121
+
122
+ /** Tracks the current route in your app. */
123
+ this.currentRoute$ = this.router.events.pipe(
124
+ filter((event) => event instanceof NavigationEnd),
125
+ map(({ urlAfterRedirects }: NavigationEnd) => urlAfterRedirects),
126
+ publishReplay(1),
127
+ ) as ConnectableObservable<string>;
128
+
129
+ // Need to manually connect to make sure it gets the first one
130
+ this.currentRoute$.connect();
131
+
132
+
133
+ /** Tracks the active time at the current route. */
134
+ this.runningTimeAtRoute$ = combineLatest([this.eventTimestamps$, this.currentRoute$]).pipe(
135
+ pairwise(),
136
+ scan((timeAtRoute, [[timestamp1, route1], [timestamp2, route2]]) => {
137
+ // Amount of inactive time that indicates not working
138
+ // We're using 1 minute for now. Could probably use longer
139
+ // cause people are likely to search for things online, and
140
+ // that shouldn't count as 'inactive' time
141
+ const BREAK_THRESHOLD = 1 * 60 * 1000;
142
+ const interval = timestamp2 - timestamp1;
143
+ const timeToRecord = interval > BREAK_THRESHOLD ? 0 : interval;
144
+ const restToRecord = interval - timeToRecord;
145
+
146
+ if (!timeAtRoute) {
147
+ // If this is the very first event pair
148
+ if (route1 === route2) {
149
+ return {
150
+ route: route1,
151
+ startTime: timestamp1,
152
+ time: [{
153
+ type: 'active',
154
+ total: timeToRecord,
155
+ }],
156
+ };
157
+ } else {
158
+ return {
159
+ route: route2,
160
+ startTime: timestamp1,
161
+ time: [{
162
+ type: 'active',
163
+ total: 0,
164
+ }],
165
+ };
166
+ }
167
+ } else {
168
+ // For the remainder of events
169
+ if (timeAtRoute.route === route2) {
170
+ const recentTimeEntry = timeAtRoute.time[timeAtRoute.time.length - 1];
171
+
172
+ if (interval === 0) {
173
+ // Some edge cases where the interval could actually be 0
174
+ return timeAtRoute;
175
+ } else if (recentTimeEntry.type === 'active' && timeToRecord > 0) {
176
+ // If this is additional active time, add it to the previous count
177
+ const newRecentTimeEntry = {
178
+ type: 'active', total: recentTimeEntry.total + timeToRecord,
179
+ };
180
+ const newTimeArr = [...timeAtRoute.time.slice(0, timeAtRoute.time.length - 1), newRecentTimeEntry];
181
+
182
+ return { route: route2, startTime: timeAtRoute.startTime, time: newTimeArr };
183
+ } else if (recentTimeEntry.type === 'rest' && timeToRecord > 0) {
184
+ // If this is new active time, make a new entry
185
+ const newTimeArr = [...timeAtRoute.time, {
186
+ type: 'active', total: timeToRecord,
187
+ }];
188
+ return { route: route2, startTime: timeAtRoute.startTime, time: newTimeArr };
189
+ } else {
190
+ // If this is rest time, make a new entry
191
+ const newTimeArr = [...timeAtRoute.time, {
192
+ type: 'rest', total: restToRecord,
193
+ }];
194
+ return { route: route2, startTime: timeAtRoute.startTime, time: newTimeArr };
195
+ }
196
+ } else {
197
+ return {
198
+ route: route2,
199
+ startTime: timestamp2,
200
+ time: [{
201
+ type: 'active', total: 0,
202
+ }],
203
+ };
204
+ }
205
+ }
206
+ }, undefined),
207
+ );
208
+
209
+ this.timeAtRoute$ = this.runningTimeAtRoute$.pipe(
210
+ pairwise(),
211
+ filter(([timeAtRoute1, timeAtRoute2]) => {
212
+ return timeAtRoute2.route !== timeAtRoute1.route;
213
+ }),
214
+ map(([timeAtRoute1, timeAtRoute2]) => timeAtRoute1),
215
+ filter((timeAtRoute: TimeAtRoute) => {
216
+ const total = timeAtRoute.time.reduce((x, y) => {
217
+ return x + y.total;
218
+ }, 0);
219
+ return total > 0;
220
+ }),
221
+ );
222
+ }
223
+ }
@@ -0,0 +1,71 @@
1
+ import { NgModule, Optional, SkipSelf, NgZone, PLATFORM_ID } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { RouterModule } from '@angular/router';
4
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
5
+ import { throwIfAlreadyLoaded } from './setup/module-import-guard';
6
+
7
+ import { environment } from '../../environments/environment';
8
+
9
+ // Firebase
10
+ import { AngularFireModule } from '@angular/fire/compat';
11
+ import { AngularFirestoreModule } from '@angular/fire/compat/firestore';
12
+ import { AngularFireAuthModule } from '@angular/fire/compat/auth';
13
+ import { MainAngularFirestore, LoggingAngularFirestore, MainAngularFirestoreFactory, LoggingAngularFirestoreFactory } from './setup/firebase-setup';
14
+
15
+ // NgRx
16
+ import { StoreModule } from '@ngrx/store';
17
+ import { reducers, metaReducers } from './store/app.reducer';
18
+ import { StoreDevtoolsModule } from '@ngrx/store-devtools';
19
+ import { StoreRouterConnectingModule, RouterState } from '@ngrx/router-store';
20
+ import { EffectsModule } from '@ngrx/effects';
21
+ import { AppEffects } from './store/app.effects';
22
+
23
+ // Auth
24
+ import { AuthEffects } from './store/auth/auth.effects';
25
+
26
+ // Entity Effects
27
+ import { UserEffects } from './store/user/user.effects';
28
+
29
+ // Service Effects
30
+ import { SnackbarEffects } from './snackbar/snackbar.effects';
31
+
32
+ @NgModule({
33
+ imports: [
34
+ CommonModule,
35
+ RouterModule,
36
+ BrowserAnimationsModule,
37
+ AngularFireModule.initializeApp(environment.firebase),
38
+ AngularFirestoreModule,
39
+ AngularFireAuthModule,
40
+ StoreModule.forRoot(reducers, {
41
+ metaReducers,
42
+ runtimeChecks: {
43
+ strictActionImmutability: false,
44
+ },
45
+ }),
46
+ StoreRouterConnectingModule.forRoot({ routerState: RouterState.Minimal }),
47
+ StoreDevtoolsModule.instrument({
48
+ maxAge: 25, // Retains last 25 states
49
+ logOnly: environment.production, // Restrict extension to log-only mode
50
+ }),
51
+ EffectsModule.forRoot([
52
+ AppEffects,
53
+ AuthEffects,
54
+ // Service Effects
55
+ SnackbarEffects,
56
+ // Entity Effects
57
+ UserEffects,
58
+ ]),
59
+ ],
60
+ declarations: [],
61
+ exports: [],
62
+ providers: [
63
+ { provide: MainAngularFirestore, deps: [PLATFORM_ID, NgZone], useFactory: MainAngularFirestoreFactory },
64
+ { provide: LoggingAngularFirestore, deps: [PLATFORM_ID, NgZone], useFactory: LoggingAngularFirestoreFactory },
65
+ ],
66
+ })
67
+ export class CoreModule {
68
+ constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
69
+ throwIfAlreadyLoaded(parentModule, 'CoreModule');
70
+ }
71
+ }