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.ts 858B

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