Source: reducers/index.js

  1. /**
  2. * @module react-cmf/lib/reducers
  3. * @see module:react-cmf/lib/reducers/collectionsReducers
  4. * @see module:react-cmf/lib/reducers/componentsReducers
  5. * @see module:react-cmf/lib/reducers/settingsReducers
  6. */
  7. import { combineReducers } from 'redux';
  8. import collectionsReducers from './collectionsReducers';
  9. import { componentsReducers } from './componentsReducers';
  10. import { settingsReducers } from './settingsReducers';
  11. import CONST from '../constant';
  12. const defaultState = [];
  13. /**
  14. * errorsReducer
  15. */
  16. function errorsReducer(state = defaultState, action) {
  17. if (action.type === CONST.ERROR) {
  18. return state.concat(action.error);
  19. }
  20. return state;
  21. }
  22. /**
  23. * exported API
  24. * @type {object}
  25. * @example
  26. import reducer from 'react-cmf/lib/reducers';
  27. */
  28. export default combineReducers({
  29. collections: collectionsReducers,
  30. components: componentsReducers,
  31. settings: settingsReducers,
  32. errors: errorsReducer,
  33. });