Choosing concurrency tools
A new iOS feature needs a network result shared across several screens, and the UI has to update too. What role would you give each of Swift Concurrency's async/await, Task, and actor?
A new iOS feature needs a network result shared across several screens, and the UI has to update too. What role would you give each of Swift Concurrency's async/await, Task, and actor?
An async function is the syntax for writing waiting work like networking in order, a Task is the entry point from synchronous code (a button tap, viewDidLoad) into that async world, and an actor wraps mutable state that several Tasks touch together, like a response cache, and serializes access. UI updates happen in a ViewModel isolated to @MainActor.
ConcurrencyShort answerBasics
In Swift, what's the difference between a class and an actor?
#swift-concurrency #actor #mainactor
SwiftUIShort answerBasics
A SwiftUI order list ViewModel calls an async API and then changes the screen state with…
#async-await #mainactor
TestingShort answerExpert
How do you reproduce or detect a data race in concurrent code that uses actors and Tasks?
#swift-concurrency #actor
ConcurrencyShort answerBasics
This code gets called from several threads, and count comes out lower than expected. Can…
#actor