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

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