mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 14:33:03 +00:00
no more build errors, still issues with the selectors not returning anything
This commit is contained in:
37
src/app/app.metareducers.ts
Normal file
37
src/app/app.metareducers.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { isNotEmpty } from './shared/empty.util';
|
||||
import { StoreActionTypes } from './store.actions';
|
||||
|
||||
// crude temporary ngrx debugger for use until
|
||||
// https://github.com/ngrx/platform/issues/97 is fixed
|
||||
let actionCounter = 0;
|
||||
|
||||
export function debugMetaReducer(reducer) {
|
||||
return (state, action) => {
|
||||
if (isNotEmpty(console.debug)) {
|
||||
actionCounter++;
|
||||
console.debug('@ngrx action', actionCounter, action.type);
|
||||
console.debug('state', state);
|
||||
console.debug('action', action);
|
||||
console.debug('------------------------------------');
|
||||
}
|
||||
|
||||
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:
|
||||
break;
|
||||
default:
|
||||
|
||||
return reducer(state, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const appMetaReducers = [debugMetaReducer, universalMetaReducer];
|
Reference in New Issue
Block a user