From: Kai Moritz Date: Fri, 26 Jun 2020 13:49:07 +0000 (+0200) Subject: Integrated debug-MetaReducer from https://ngrx.io/guide/store/metareducers X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=5bf0ea327ad86bcadc47bce2c0d389511587ea0d;p=examples%2Fangular-tour-of-heroes Integrated debug-MetaReducer from https://ngrx.io/guide/store/metareducers --- 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 ] : [];