Skip to content

Instantly share code, notes, and snippets.

@mordaha
Last active January 26, 2017 15:19
Show Gist options
  • Save mordaha/4a09675d776ef5cfa05d126ed643b59c to your computer and use it in GitHub Desktop.
Save mordaha/4a09675d776ef5cfa05d126ed643b59c to your computer and use it in GitHub Desktop.
export const getFacilityInfo = idList => async (dispatch, getState) => {
// 0
const facilityById = selectors.getFacilityById(getState());
const facilityIdList = idList || facilityById.keys;
if (facilityIdList.length === 0) {
return;
}
let data;
try {
data = await api.facilityGet(...facilityIdList);
} catch (ex) {
// 2
return;
}
if (data.error) {
// 3
console.log('facilityGet error', data.error); // eslint-disable-line
} else {
// 1
const updatedFacilityById = normalizeFacilityData(facilityById, data);
// 1.1
await asyncActions.resetSomeHalfOfAppData();
// 1.2
dispatch(plainActions.mergeFacilityById(updatedFacilityById));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment