I'm looking for a solution in Swift3 to resolve a dynamic number of promises all at once, e.g. like this sample in JavaScript:
var promises = [];
for(var i = 0; i < 5; i++) {
var promise = $http.get('/data' + i);
promises.push(promise);
}
$q.all(promises).then(doSomethingAfterAllRequests);
https://daveceddia.com/waiting-for-promises-in-a-loop/
There was a library call 'Craft' for Swift2 that could do that (https://github.com/supertommy/craft), but it's no longer maintained.
Does anyone know if or how I could do that with PromiseKit or another library?
Thx a bunch!
SWIFT is an acronym for the Society for Worldwide Interbank Financial Telecommunications and may also be referred to as a CIC code.
History. SWIFT was founded in Brussels on 3 May 1973 under the leadership of its inaugural Swedish CEO, Carl Reuterskiöld (1973–1989), a former employee at Wallenberg-owned Skandinaviska Enskilda Banken, and was supported by 239 banks in 15 countries.
SWIFT is overseen by the G-10 central banks (Belgium, Canada, France, Germany, Italy, Japan, The Netherlands, United Kingdom, United States, Switzerland, and Sweden), as well as the European Central Bank, with its lead overseer being the National Bank of Belgium.
The SWIFT payment network allows individuals and businesses to accept/send international money via electronic or credit card payments. This can be done even if the customer or vendor uses a different bank than the payee. The network is a place for secure financial messaging.
You can look into when
which may provide what you need and is covered here.
Use the loop to put your promises into an array and then do something like this:
when(fulfilled: promiseArray).then { results in
// Do something
}.catch { error in
// Handle error
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With