From 5bf0ea327ad86bcadc47bce2c0d389511587ea0d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 26 Jun 2020 15:49:07 +0200 Subject: [PATCH] Integrated debug-MetaReducer from https://ngrx.io/guide/store/metareducers --- src/app/reducers/debug.ts | 11 +++++++++++ src/app/reducers/index.ts | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/app/reducers/debug.ts diff --git a/src/app/reducers/debug.ts b/src/app/reducers/debug.ts new file mode 100644 index 0000000..338a42d --- /dev/null +++ b/src/app/reducers/debug.ts @@ -0,0 +1,11 @@ +import { ActionReducer } from '@ngrx/store'; + +// console.log all actions +export function debug(reducer: ActionReducer): ActionReducer { + return function(state, action) { + console.log('state', state); + console.log('action', action); + + return reducer(state, action); + }; +} diff --git a/src/app/reducers/index.ts b/src/app/reducers/index.ts index 96a875b..4952a9b 100644 --- a/src/app/reducers/index.ts +++ b/src/app/reducers/index.ts @@ -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 = { }; -export const metaReducers: MetaReducer[] = !environment.production ? [] : []; +export const metaReducers: MetaReducer[] = !environment.production ? [ debug ] : []; -- 2.20.1