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.js 859B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { ReducerRegistry } from '../base/redux';
  2. import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
  3. /**
  4. * The initial Redux state of features/app.
  5. */
  6. const INITIAL_STATE = {
  7. /**
  8. * The one and only (i.e. singleton) App instance which is currently
  9. * mounted.
  10. *
  11. * @type {App}
  12. */
  13. app: undefined
  14. };
  15. ReducerRegistry.register('features/app', (state = INITIAL_STATE, action) => {
  16. switch (action.type) {
  17. case APP_WILL_MOUNT:
  18. if (state.app !== action.app) {
  19. return {
  20. ...state,
  21. app: action.app
  22. };
  23. }
  24. break;
  25. case APP_WILL_UNMOUNT:
  26. if (state.app === action.app) {
  27. return {
  28. ...state,
  29. app: INITIAL_STATE.app
  30. };
  31. }
  32. break;
  33. }
  34. return state;
  35. });