Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Apr 13, 2020
1 parent d18d3e7 commit 61fed69
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions x-pack/legacy/plugins/maps/public/actions/map_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,21 @@ async function syncDataForAllLayers(dispatch, getState, dataFilters) {
export function cancelAllInFlightRequests() {
return (dispatch, getState) => {
getLayerList(getState()).forEach(layer => {
layer.getInFlightRequestTokens().forEach(requestToken => {
dispatch(cancelRequest(requestToken));
});
dispatch(clearDataRequests(layer));
});
};
}

function clearDataRequests(layer) {
return dispatch => {
layer.getInFlightRequestTokens().forEach(requestToken => {
dispatch(cancelRequest(requestToken));
});
dispatch({
type: UPDATE_LAYER_PROP,
id: layer.getId(),
propName: '__dataRequests',
newValue: [],
});
};
}
Expand Down Expand Up @@ -678,15 +690,7 @@ function updateLayerType(layerId, newLayerType) {
if (!layer || layer.getType() === newLayerType) {
return;
}
layer.getInFlightRequestTokens().forEach(requestToken => {
dispatch(cancelRequest(requestToken));
});
dispatch({
type: UPDATE_LAYER_PROP,
id: layerId,
propName: '__dataRequests',
newValue: [],
});
dispatch(clearDataRequests(layer));
dispatch({
type: UPDATE_LAYER_PROP,
id: layerId,
Expand Down

0 comments on commit 61fed69

Please sign in to comment.