2016-10-05 14:36:59 +00:00
|
|
|
import { ReducerRegistry } from '../base/redux';
|
|
|
|
|
2017-01-15 04:05:56 +00:00
|
|
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2016-12-07 22:08:35 +00:00
|
|
|
ReducerRegistry.register('features/app', (state = {}, action) => {
|
2016-10-05 14:36:59 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case APP_WILL_MOUNT:
|
|
|
|
if (state.app !== action.app) {
|
|
|
|
return {
|
|
|
|
...state,
|
2016-12-07 22:08:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The one and only (i.e. singleton) App instance which is
|
|
|
|
* currently mounted.
|
|
|
|
*
|
|
|
|
* @type {App}
|
|
|
|
*/
|
2016-10-05 14:36:59 +00:00
|
|
|
app: action.app
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case APP_WILL_UNMOUNT:
|
|
|
|
if (state.app === action.app) {
|
|
|
|
return {
|
|
|
|
...state,
|
2016-12-07 22:08:35 +00:00
|
|
|
app: undefined
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|