Saúl Ibarra Corretgé dc246960df feat(App): refactor App and split it into BaseApp and App
BaseApp does all the heavy-lifting related to creating the redux store,
navigation, and so on.

App currently handles URL props and actually triggering navigation based on
them.
2018-07-12 11:28:19 -05:00

40 lines
862 B
JavaScript

// @flow
import { ReducerRegistry } from '../redux';
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
ReducerRegistry.register('features/base/app', (state = {}, action) => {
switch (action.type) {
case APP_WILL_MOUNT: {
const { app } = action;
if (state.app !== app) {
return {
...state,
/**
* The one and only (i.e. singleton) {@link BaseApp} instance
* which is currently mounted.
*
* @type {BaseApp}
*/
app
};
}
break;
}
case APP_WILL_UNMOUNT:
if (state.app === action.app) {
return {
...state,
app: undefined
};
}
break;
}
return state;
});