Integrated debug-MetaReducer from https://ngrx.io/guide/store/metareducers
[examples/angular-tour-of-heroes] / src / app / reducers / debug.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);
+  };
+}