mainactor Questions
2
Solved
We'd like to make use of the @MainActor Annotation for our ViewModels in an existing SwiftUI project, so we can get rid of DispatchQueue.main.async and .receive(on: RunLoop.main).
@MainActor
class ...
Notional asked 3/11, 2022 at 12:55
6
Solved
I'm trying out the new async/await stuff. My goal here is to run the test() method in the background, so I use Task.detached; but during test() I need to make a call on the main thread, so I'm usin...
Ably asked 10/6, 2021 at 2:17
1
Solved
I would like to understand if it's needed to declare the Task itself as MainActor considering the following block of code.
func login() {
Task { [weak self] in
let result = await self?.loginServi...
Lipoprotein asked 19/4, 2022 at 10:33
1
Solved
I've got an ObservableObject class that I am calling to via @StateObject from my view. Inside that class is a function and the entire class is marked @MainActor. In my view there is a TextField wit...
Epilimnion asked 12/2, 2022 at 0:45
1
Solved
I’m studying async, await, @MainActor of Swift.
I want to run a long process and display the progress.
import SwiftUI
@MainActor
final class ViewModel: ObservableObject {
@Published var count = 0...
Leger asked 7/1, 2022 at 8:33
1
© 2022 - 2024 — McMap. All rights reserved.