您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

reducer.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { ReducerRegistry } from '../base/redux';
  2. import {
  3. HIDE_NOTIFICATION,
  4. SHOW_NOTIFICATION
  5. } from './actionTypes';
  6. /**
  7. * The initial state of the feature notifications.
  8. *
  9. * @type {array}
  10. */
  11. const DEFAULT_STATE = [];
  12. /**
  13. * Reduces redux actions which affect the display of notifications.
  14. *
  15. * @param {Object} state - The current redux state.
  16. * @param {Object} action - The redux action to reduce.
  17. * @returns {Object} The next redux state which is the result of reducing the
  18. * specified {@code action}.
  19. */
  20. ReducerRegistry.register('features/notifications',
  21. (state = DEFAULT_STATE, action) => {
  22. switch (action.type) {
  23. case HIDE_NOTIFICATION:
  24. return state.filter(
  25. notification => notification.uid !== action.uid);
  26. case SHOW_NOTIFICATION:
  27. return [
  28. ...state,
  29. {
  30. component: action.component,
  31. props: action.props,
  32. timeout: action.timeout,
  33. uid: action.uid
  34. }
  35. ];
  36. }
  37. return state;
  38. });