Lyubomir Marinov 62bafcaf63 Introduce Platform in React
React Native provides a Platform abstraction which React does not
provide.
2017-01-26 07:27:31 -06:00

35 lines
814 B
JavaScript

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