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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // @flow
  2. import { Transport } from '../../../modules/transport';
  3. import { ReducerRegistry, set } from '../base/redux';
  4. import {
  5. SET_TRANSPORT,
  6. SUSPEND_DETECTED
  7. } from './actionTypes';
  8. /**
  9. * Reduces the redux actions of the feature power monitor.
  10. */
  11. ReducerRegistry.register('features/power-monitor', (state = { }, action) => {
  12. switch (action.type) {
  13. case SET_TRANSPORT:
  14. return _setTransport(state, action.transport);
  15. case SUSPEND_DETECTED:
  16. return _suspendDetected(state);
  17. }
  18. return state;
  19. });
  20. /**
  21. * Reduces a specific redux action SET_TRANSPORT of the feature power monitor.
  22. *
  23. * @param {Object} state - The redux state of the feature power monitor.
  24. * @param {?Transport} transport - The transport to store in state.
  25. * @private
  26. * @returns {Object} The new state of the feature power monitor after the reduction of
  27. * the specified action.
  28. */
  29. function _setTransport(state, transport: ?Transport) {
  30. return set(state, 'transport', transport);
  31. }
  32. /**
  33. * Reduces a specific redux action SUSPEND_DETECTED of the feature overlay.
  34. *
  35. * @param {Object} state - The redux state of the feature overlay.
  36. * @private
  37. * @returns {Object} The new state of the feature overlay after the reduction of
  38. * the specified action.
  39. */
  40. function _suspendDetected(state) {
  41. return set(state, 'suspendDetected', true);
  42. }