Just put @MainActor
before defining your class that is supposed to act in the main thread. And it’s so simple in terms of using new Swift concurrency.
@MainActor class DocumentsViewModel: ObservableObject { ... }
There’s a lot of information about that in new WWDC 2021 videos or articles like that: Using the MainActor attribute to automatically dispatch UI updates on the main queue