index.ts 884 B

123456789101112131415161718192021222324252627
  1. import * as mainActions from './main';
  2. import * as pdfActions from './pdf';
  3. import * as types from '../constants/actionTypes';
  4. const createReducer = (handlers: {[key: string]: any}) => (
  5. state: Record<string, any>,
  6. action: { type: string },
  7. ): any => {
  8. if (!Object.prototype.hasOwnProperty.call(handlers, action.type)) {
  9. return state;
  10. }
  11. return handlers[action.type](state, action);
  12. };
  13. export default createReducer({
  14. [types.SWITCH_NAVBAR]: mainActions.setNavbarState,
  15. [types.SWITCH_SIDEBAR]: mainActions.setSidebarState,
  16. [types.SET_CURRENT_PAGE]: pdfActions.setCurrentPage,
  17. [types.SET_TOTAL_PAGE]: pdfActions.setTotalPage,
  18. [types.SET_PDF]: pdfActions.setPdf,
  19. [types.SET_PROGRESS]: pdfActions.setProgress,
  20. [types.SET_VIEWPORT]: pdfActions.setViewport,
  21. [types.CHANGE_SCALE]: pdfActions.changeScale,
  22. [types.CHANGE_ROTATE]: pdfActions.changeRotate,
  23. });