Fetch topologies sequentially on search

This commit is contained in:
David Kaltschmidt
2016-05-10 18:33:42 +02:00
parent 9984777a5b
commit 50935dd456

View File

@@ -102,12 +102,15 @@ function createWebsocket(topologyUrl, optionsQuery, dispatch) {
export function getAllNodes(getState, dispatch) {
const state = getState();
const topologyOptions = state.get('topologyOptions');
state.get('topologyUrlsById').forEach((topologyUrl, topologyId) => {
const optionsQuery = buildOptionsQuery(topologyOptions.get(topologyId));
fetch(`${topologyUrl}?${optionsQuery}`)
.then(response => response.json())
.then(json => dispatch(receiveNodesForTopology(json.nodes, topologyId)));
});
// fetch sequentially
state.get('topologyUrlsById')
.reduce((sequence, topologyUrl, topologyId) => sequence.then(() => {
const optionsQuery = buildOptionsQuery(topologyOptions.get(topologyId));
return fetch(`${topologyUrl}?${optionsQuery}`);
})
.then(response => response.json())
.then(json => dispatch(receiveNodesForTopology(json.nodes, topologyId))),
Promise.resolve());
}
export function getTopologies(options, dispatch) {