您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.ts 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { IStore } from '../../app/types';
  2. import {
  3. APP_WILL_MOUNT,
  4. APP_WILL_NAVIGATE,
  5. APP_WILL_UNMOUNT
  6. } from './actionTypes';
  7. /**
  8. * Signals that a specific App will mount (in the terms of React).
  9. *
  10. * @param {App} app - The App which will mount.
  11. * @returns {{
  12. * type: APP_WILL_MOUNT,
  13. * app: App
  14. * }}
  15. */
  16. export function appWillMount(app: Object) {
  17. return (dispatch: IStore['dispatch']) => {
  18. // TODO There was a redux action creator appInit which I did not like
  19. // because we already had the redux action creator appWillMount and,
  20. // respectively, the redux action APP_WILL_MOUNT. So I set out to remove
  21. // appInit and managed to move everything it was doing but the
  22. // following. Which is not extremely bad because we haven't moved the
  23. // API module into its own feature yet so we're bound to work on that in
  24. // the future.
  25. typeof APP === 'object' && APP.API.init();
  26. dispatch({
  27. type: APP_WILL_MOUNT,
  28. app
  29. });
  30. };
  31. }
  32. /**
  33. * Signals that a specific App will unmount (in the terms of React).
  34. *
  35. * @param {App} app - The App which will unmount.
  36. * @returns {{
  37. * type: APP_WILL_UNMOUNT,
  38. * app: App
  39. * }}
  40. */
  41. export function appWillUnmount(app: Object) {
  42. return {
  43. type: APP_WILL_UNMOUNT,
  44. app
  45. };
  46. }
  47. /**
  48. * Signals that a specific App will navigate (in the terms of React).
  49. *
  50. * @param {App} app - The App which will navigate.
  51. * @param {Object} route - The route which will be used.
  52. * @returns {{
  53. * type: APP_WILL_NAVIGATE,
  54. * app: App,
  55. * route: Object
  56. * }}
  57. */
  58. export function appWillNavigate(app: Object, route: Object) {
  59. return {
  60. type: APP_WILL_NAVIGATE,
  61. app,
  62. route
  63. };
  64. }