68 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-09-25 21:54:59 +02:00
/**
2016-10-05 14:18:26 +02:00
* The home state selectors
2016-09-25 21:54:59 +02:00
*/
import { createSelector } from 'reselect';
2016-10-05 14:18:26 +02:00
/*
* Select home state
*/
2016-09-25 21:54:59 +02:00
const selectHome = () => (state) => state.get('home');
const selectLoading = () => createSelector(
selectHome(),
(homeState) => homeState.get('loading')
);
const selectError = () => createSelector(
selectHome(),
(homeState) => homeState.get('error')
);
const selectGeneralSettings = () => createSelector(
selectHome(),
(homeState) => homeState.get('generalSettings')
);
2016-09-26 17:28:40 +02:00
const selectName = () => createSelector(
selectHome(),
(homeState) => homeState.get('name')
);
2016-09-26 18:28:32 +02:00
const selectDescription = () => createSelector(
selectHome(),
(homeState) => homeState.get('description')
);
const selectVersion = () => createSelector(
selectHome(),
(homeState) => homeState.get('version')
);
2016-09-25 21:54:59 +02:00
const selectLocationState = () => {
let prevRoutingState;
let prevRoutingStateJS;
return (state) => {
const routingState = state.get('route'); // or state.route
if (!routingState.equals(prevRoutingState)) {
prevRoutingState = routingState;
prevRoutingStateJS = routingState.toJS();
}
return prevRoutingStateJS;
};
};
export {
selectHome,
selectLoading,
selectError,
selectGeneralSettings,
2016-09-26 17:28:40 +02:00
selectName,
2016-09-26 18:28:32 +02:00
selectDescription,
selectVersion,
2016-09-25 21:54:59 +02:00
selectLocationState,
};