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 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // @flow
  2. import { equals, ReducerRegistry } from '../redux';
  3. import { SET_LOGGING_CONFIG } from './actionTypes';
  4. /**
  5. * The default/initial redux state of the feature base/logging.
  6. *
  7. * @type {{
  8. * config: Object
  9. * }}
  10. */
  11. const DEFAULT_STATE = {
  12. config: require('../../../../logging_config.js')
  13. };
  14. ReducerRegistry.register(
  15. 'features/base/logging',
  16. (state = DEFAULT_STATE, action) => {
  17. switch (action.type) {
  18. case SET_LOGGING_CONFIG:
  19. return _setLoggingConfig(state, action);
  20. default:
  21. return state;
  22. }
  23. });
  24. /**
  25. * Reduces a specific Redux action SET_LOGGING_CONFIG of the feature
  26. * base/logging.
  27. *
  28. * @param {Object} state - The Redux state of the feature base/logging.
  29. * @param {Action} action - The Redux action SET_LOGGING_CONFIG to reduce.
  30. * @private
  31. * @returns {Object} The new state of the feature base/logging after the
  32. * reduction of the specified action.
  33. */
  34. function _setLoggingConfig(state, action) {
  35. const config = {
  36. // The config of DEFAULT_STATE is the default configuration of the
  37. // feature base/logging.
  38. ...DEFAULT_STATE.config,
  39. ...action.config
  40. };
  41. if (equals(state.config, config)) {
  42. return state;
  43. }
  44. return {
  45. ...state,
  46. config
  47. };
  48. }