mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 06:23:03 +00:00
38 lines
910 B
TypeScript
38 lines
910 B
TypeScript
import { StoreActionTypes } from './store.actions';
|
|
|
|
// fallback ngrx debugger
|
|
let actionCounter = 0;
|
|
|
|
export function debugMetaReducer(reducer) {
|
|
return (state, action) => {
|
|
actionCounter++;
|
|
console.log('@ngrx action', actionCounter, action.type);
|
|
console.log('state', JSON.stringify(state));
|
|
console.log('action', JSON.stringify(action));
|
|
console.log('------------------------------------');
|
|
return reducer(state, action);
|
|
};
|
|
}
|
|
|
|
export function universalMetaReducer(reducer) {
|
|
return (state, action) => {
|
|
switch (action.type) {
|
|
case StoreActionTypes.REHYDRATE:
|
|
state = Object.assign({}, state, action.payload);
|
|
break;
|
|
case StoreActionTypes.REPLAY:
|
|
default:
|
|
break;
|
|
}
|
|
return reducer(state, action);
|
|
};
|
|
}
|
|
|
|
export const debugMetaReducers = [
|
|
debugMetaReducer,
|
|
];
|
|
|
|
export const appMetaReducers = [
|
|
universalMetaReducer,
|
|
];
|