Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import { Action, ActionReducer, MetaReducer } from '@ngrx/store';
  2. import { environment } from 'src/environments/environment';
  3. import { storeFreeze } from 'ngrx-store-freeze';
  4.  
  5. export function debugMetaReducer(
  6. reducer: ActionReducer<object>
  7. ): ActionReducer<object> {
  8. return function(oldState: object, action: Action): object {
  9. const newState = reducer(oldState, action);
  10. console.groupCollapsed(
  11. `%c NgRx store update by '${action.type}'`,
  12. 'color: #e2001a'
  13. );
  14. console.log('Old state: ', oldState);
  15. console.log('Action: ', action);
  16. console.log('New state: ', newState);
  17. console.groupEnd();
  18.  
  19. return newState;
  20. };
  21. }
  22.  
  23. export const metaReducers: MetaReducer<any>[] = [debugMetaReducer, storeFreeze];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement