import { environment } from '@env/environment'; // import { storeFreeze } from 'ngrx-store-freeze'; import { MetaReducer, ActionReducer } from '@ngrx/store'; import { State } from './state'; // storeStateGuard会处理登出的情况,需要用到authActions import * as authActions from 'app/actions/auth.action'; export function logger(reducer: ActionReducer): ActionReducer { return function(state: State, action: any): State { console.log('state', state); console.log('action', action); return reducer(state, action); }; } export function storeStateGuard(reducer: ActionReducer): ActionReducer { return function(state: State, action: any): State { if (action.type === authActions.Logout) { return reducer( undefined, action); } return reducer(state, action); }; } export const metaReducers: MetaReducer[] = !environment.production ? [ // 系统自待 // storeFreeze, // 自己实现的 logger, storeStateGuard, ] : [storeStateGuard];