Integrated debug-MetaReducer from https://ngrx.io/guide/store/metareducers
authorKai Moritz <kai@juplo.de>
Fri, 26 Jun 2020 13:49:07 +0000 (15:49 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 5 Jul 2020 08:39:23 +0000 (10:39 +0200)
src/app/reducers/debug.ts [new file with mode: 0644]
src/app/reducers/index.ts

diff --git a/src/app/reducers/debug.ts b/src/app/reducers/debug.ts
new file mode 100644 (file)
index 0000000..338a42d
--- /dev/null
@@ -0,0 +1,11 @@
+import { ActionReducer } from '@ngrx/store';
+
+// console.log all actions
+export function debug(reducer: ActionReducer<any>): ActionReducer<any> {
+  return function(state, action) {
+    console.log('state', state);
+    console.log('action', action);
+
+    return reducer(state, action);
+  };
+}
index 96a875b..4952a9b 100644 (file)
@@ -7,6 +7,7 @@ import {
 } from '@ngrx/store';
 import { environment } from '../../environments/environment';
 import * as fromVorgang from './vorgang';
+import { debug } from './debug';
 
 export interface State {
 
@@ -17,4 +18,4 @@ export const reducers: ActionReducerMap<State> = {
 };
 
 
-export const metaReducers: MetaReducer<State>[] = !environment.production ? [] : [];
+export const metaReducers: MetaReducer<State>[] = !environment.production ? [ debug ] : [];