Reading List
Where View.task Gets Its Main-actor Isolation From from Michael Tsai RSS feed.
Where View.task Gets Its Main-actor Isolation From
Ole Begemann: SwiftUI’s .task modifier inherits its actor context from the surrounding function. If you call .task inside a view’s body property, the async operation will run on the main actor because View.body is (semi-secretly) annotated with @MainActor. However, if you call .task from a helper property or function that isn’t @MainActor-annotated, the async operation […]