Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

reducer.ts 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { AnyAction } from 'redux';
  2. import ReducerRegistry from '../redux/ReducerRegistry';
  3. import { assign } from '../redux/functions';
  4. import { SET_CONNECTION_STATE } from './actionTypes';
  5. /**
  6. * The initial state of the feature testing.
  7. *
  8. * @type {{
  9. * connectionState: string
  10. * }}
  11. */
  12. const INITIAL_STATE = {
  13. connectionState: ''
  14. };
  15. export interface ITestingState {
  16. connectionState: string;
  17. }
  18. ReducerRegistry.register<ITestingState>(
  19. 'features/testing',
  20. (state = INITIAL_STATE, action): ITestingState => {
  21. switch (action.type) {
  22. case SET_CONNECTION_STATE:
  23. return _setConnectionState(state, action);
  24. default:
  25. return state;
  26. }
  27. });
  28. /**
  29. * Reduces a specific Redux action SET_CONNECTION_STATE of the feature
  30. * testing.
  31. *
  32. * @param {Object} state - The Redux state of the feature base/logging.
  33. * @param {Action} action - The Redux action SET_CONNECTION_STATE to reduce.
  34. * @private
  35. * @returns {Object} The new state of the feature testing after the
  36. * reduction of the specified action.
  37. */
  38. function _setConnectionState(state: ITestingState, action: AnyAction) {
  39. return assign(state, { connectionState: action.connectionState });
  40. }