-
The most typical way to solve this problem is by using Combine's Future or PromiseKit's Promise, or by using RxSwift's flatMap. If you're interested on how this works under the hood, I plan to write another article for this case, but for now you can check my code for a simple Promise in this gist, or check this quite old but incredibly mind blowing talk from Javi Soto.
-
InfluxDB
Purpose built for real-time analytics at any scale. InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.
-
We have defined what async code is, and two basic issues we could have when working with it: running tasks serially and in parallel. For running tasks in parallel we saw that DispatchGroup can be a simple solution for that. I will recommend using a library for this though. What I taught you here is basic async knowledge, but in real world scenarios, this won't be this straightforward, so using a battle tested library is always an advantage when working in production. I personally recommend using Apple's Combine if you can (it is supported in iOS 13 and above) or using RxSwift otherwise Finally, I can't finish this article without mentioning async-await. With async-await, probably all of this discussion will be a thing of the past. It lets us write async code that can be written like sync code. You can see the proposal (already implemented and that will be released in the next version of swift) here, and even try it in your code following a tutorial like this one.