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.

123456789101112131415161718192021222324252627282930313233343536
  1. import ReducerRegistry from '../../base/redux/ReducerRegistry';
  2. import {
  3. APP_STATE_CHANGED,
  4. _SET_APP_STATE_LISTENER
  5. } from './actionTypes';
  6. export interface IBackgroundState {
  7. appState: string;
  8. appStateListener?: Function;
  9. }
  10. /**
  11. * The default/initial redux state of the feature background.
  12. */
  13. const DEFAULT_STATE = {
  14. appState: 'active'
  15. };
  16. ReducerRegistry.register<IBackgroundState>('features/background', (state = DEFAULT_STATE, action): IBackgroundState => {
  17. switch (action.type) {
  18. case _SET_APP_STATE_LISTENER:
  19. return {
  20. ...state,
  21. appStateListener: action.listener
  22. };
  23. case APP_STATE_CHANGED:
  24. return {
  25. ...state,
  26. appState: action.appState
  27. };
  28. }
  29. return state;
  30. });