Last active
January 26, 2017 15:19
-
-
Save mordaha/4a09675d776ef5cfa05d126ed643b59c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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