RSSAmplifier

Ole Begemann · Oct 11, 2022

Where View.task gets its main-actor isolation from

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

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 will run in the cooperative thread pool.…

Read on oleb.net

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.