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 843B

123456789101112131415161718192021222324252627282930313233
  1. // @flow
  2. import _ from 'lodash';
  3. import { ReducerRegistry } from '../redux';
  4. import { UPDATE_FLAGS } from './actionTypes';
  5. /**
  6. * Default state value for the feature flags.
  7. */
  8. const DEFAULT_STATE = {};
  9. /**
  10. * Reduces redux actions which handle feature flags.
  11. *
  12. * @param {State} state - The current redux state.
  13. * @param {Action} action - The redux action to reduce.
  14. * @param {string} action.type - The type of the redux action to reduce.
  15. * @returns {State} The next redux state that is the result of reducing the
  16. * specified action.
  17. */
  18. ReducerRegistry.register('features/base/flags', (state = DEFAULT_STATE, action) => {
  19. switch (action.type) {
  20. case UPDATE_FLAGS: {
  21. const newState = _.merge({}, state, action.flags);
  22. return _.isEqual(state, newState) ? state : newState;
  23. }
  24. }
  25. return state;
  26. });