-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MainActor issue with ObservableObject's #135
Comments
If you mark the entire class that way then you need to mark the initializer as nonisolated in order to get around that particular problem. Marking the entire class with MainActor marks every function and method within the class as MainActor, including the initializer. I tend to prefer marking async functions as MainActor as needed, and not the entire class. I wrote a lot about that on Medium: https://betterprogramming.pub/async-await-and-mainactor-strategies-cc35b6c58b52 |
just came across this, you can also do this I believe: extension Container {
var homeViewModel: Factory<HomeViewModel> {
self { @MainActor in HomeViewModel() }
}
} |
I take it back, that doesn't work. see #211 for a good answer. |
I am getting an error when trying to register an
ObservableObject
marked with@MainActor
Here's how I am registering the object:
And here is the object itself:
Is it possible to keep the
@MainActor
tag?The text was updated successfully, but these errors were encountered: