6 ms·
I don't really know Swift, but does the following line from that site make any sense? "And with Swift concurrency, it’s easy to request weather data with just
by robsws 4y ago
I don't really know Swift, but does the following line from that site make any sense?
"And with Swift concurrency, it’s easy to request weather data with just a few lines of code."
- danhau 4y agoI think it just says it‘s easy to request weather data concurrently and to integrate that into other concurrency stuff, thanks to Swift. But I‘ve never used Swift so I don‘t know.
- dbbk 4y agoBasically just saying you can use async/await to fetch the data, I think
- deleted 4y ago[deleted]
- dagmx 4y agoWithout Swift Concurrency, you'd write something like this (pseudocode): GetWeather() { results in // Do something with the results UpdateUI(results) } The part in the curly braces is a closure/completion handler. The GetWeather call is not blocking, so it runs on another thread and then it calls your completion code when it's done. This looks fine in a small example, but it quickly gets gnarly when you need to pipe those results to something else, or you can also end up deep in many completion handlers. With the new concurrency model it's just this let results = await GetWeather () UpdateUI(results) Now let's say your UpdateUI call was also non blocking: GetWeather() { results in UpdateUI(results) { DoSomethingElse () } } Which just becomes this let results = await GetWeather () await UpdateUI(results) DoSomethingElse()