index.ts 835 B

123456789101112131415161718192021222324
  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}) => (state: Object, action: { type: string }) => {
  5. if(!handlers.hasOwnProperty(action.type)) {
  6. return state;
  7. }
  8. return handlers[action.type](state, action);
  9. };
  10. export default createReducer({
  11. [types.SWITCH_NAVBAR]: mainActions.setNavbarState,
  12. [types.SWITCH_SIDEBAR]: mainActions.setSidebarState,
  13. [types.SET_CURRENT_PAGE]: pdfActions.setCurrentPage,
  14. [types.SET_TOTAL_PAGE]: pdfActions.setTotalPage,
  15. [types.SET_PDF]: pdfActions.setPdf,
  16. [types.SET_PROGRESS]: pdfActions.setProgress,
  17. [types.SET_VIEWPORT]: pdfActions.setViewport,
  18. [types.CHANGE_SCALE]: pdfActions.changeScale,
  19. [types.CHANGE_ROTATE]: pdfActions.changeRotate,
  20. });