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.js 1.3KB

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