2022-07-01 09:32:39 +00:00
|
|
|
import ReducerRegistry from '../redux/ReducerRegistry';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-06-09 19:09:23 +00:00
|
|
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2022-07-01 09:32:39 +00:00
|
|
|
export interface IAppState {
|
2022-09-23 08:13:32 +00:00
|
|
|
app?: any;
|
2022-07-01 09:32:39 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<IAppState>('features/base/app', (state = {}, action): IAppState => {
|
2016-10-05 14:36:59 +00:00
|
|
|
switch (action.type) {
|
2017-06-09 19:09:23 +00:00
|
|
|
case APP_WILL_MOUNT: {
|
|
|
|
const { app } = action;
|
|
|
|
|
|
|
|
if (state.app !== app) {
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-06-09 19:09:23 +00:00
|
|
|
app
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
2017-06-09 19:09:23 +00:00
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
});
|