You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reducer.ts 715B

12345678910111213141516171819202122232425262728293031323334
  1. import ReducerRegistry from '../redux/ReducerRegistry';
  2. import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
  3. export interface IAppState {
  4. app?: Object|undefined;
  5. }
  6. ReducerRegistry.register('features/base/app', (state: IAppState = {}, action) => {
  7. switch (action.type) {
  8. case APP_WILL_MOUNT: {
  9. const { app } = action;
  10. if (state.app !== app) {
  11. return {
  12. ...state,
  13. app
  14. };
  15. }
  16. break;
  17. }
  18. case APP_WILL_UNMOUNT:
  19. if (state.app === action.app) {
  20. return {
  21. ...state,
  22. app: undefined
  23. };
  24. }
  25. break;
  26. }
  27. return state;
  28. });