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.

actions.ts 1.3KB

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