Open eklem opened 6 years ago
https://daveceddia.com/waiting-for-promises-in-a-loop/
Use the second example, then it's easier to add a play-nice timer between each fetch() request:
fetch()
var chain = $q.when(); for(var i = 0; i < 5; i++) { chain = chain.then(function() { return $http.get('/data' + i); }); }
After the foor-loop a search-index adder can be called.
Actually, no. Do one and one, and let search-index-housekeeper keep track of whats indexed and not. We don't know when the user will click to a new page.
Or if an array: https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html
Check promise.all
https://daveceddia.com/waiting-for-promises-in-a-loop/
Use the second example, then it's easier to add a play-nice timer between each
fetch()
request:After the foor-loop a search-index adder can be called.