Ole Begemann 10/11/2022

Where View.task gets its main-actor isolation from

Read Original

This technical article details how SwiftUI's .task modifier inherits its actor context from the surrounding function. It explains that when called inside a view's @MainActor-annotated body property, the async code runs on the main actor, but not when called from a non-annotated helper. The post investigates the hidden @MainActor(unsafe) and @_inheritActorContext annotations in SwiftUI's module interface files.

Where View.task gets its main-actor isolation from

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week