2018-07-11 09:42:43 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2018-07-11 09:42:43 +00:00
|
|
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
|
|
|
|
|
|
|
|
declare var APP;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that a specific App will mount (in the terms of React).
|
|
|
|
*
|
|
|
|
* @param {App} app - The App which will mount.
|
|
|
|
* @returns {{
|
|
|
|
* type: APP_WILL_MOUNT,
|
|
|
|
* app: App
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function appWillMount(app: Object) {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>) => {
|
2018-07-11 09:42:43 +00:00
|
|
|
// TODO There was a redux action creator appInit which I did not like
|
|
|
|
// because we already had the redux action creator appWillMount and,
|
|
|
|
// respectively, the redux action APP_WILL_MOUNT. So I set out to remove
|
|
|
|
// appInit and managed to move everything it was doing but the
|
|
|
|
// following. Which is not extremely bad because we haven't moved the
|
|
|
|
// API module into its own feature yet so we're bound to work on that in
|
|
|
|
// the future.
|
|
|
|
typeof APP === 'object' && APP.API.init();
|
2019-05-19 16:23:28 +00:00
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: APP_WILL_MOUNT,
|
|
|
|
app
|
|
|
|
});
|
2018-07-11 09:42:43 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signals that a specific App will unmount (in the terms of React).
|
|
|
|
*
|
|
|
|
* @param {App} app - The App which will unmount.
|
|
|
|
* @returns {{
|
|
|
|
* type: APP_WILL_UNMOUNT,
|
|
|
|
* app: App
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function appWillUnmount(app: Object) {
|
|
|
|
return {
|
|
|
|
type: APP_WILL_UNMOUNT,
|
|
|
|
app
|
|
|
|
};
|
|
|
|
}
|