-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Can't use existential 'any' with InjectedObject property wrapper #170
Comments
You might take a look at the following. https://medium.com/swlh/did-swiftui-just-kill-protocol-oriented-programming-c09c2787172 Making the VM a protocol is a bad idea, and suffers from a plethora of problems. |
I have read the article and the SO question, the article strongly recommends to inject a loader object into the view model and this loader can be safely a protocol not the view model itself, which I exactly did in my real project, but the view model itself, in a real world example, is not a simple |
This is really an issue with Swift and associated types and there really isn't a lot I can do about it other than say, "Don't do that." If the VM is as complex as you say, then IMHO that's even more reason to follow the advice I gave in the article so that you can test the code appropriately. A VM doesn't exist in a vacuum. If you change its dependencies and/or parameters then you should be able to mock any associated behavior. |
Thank you for the advice anyway. |
I can't use the existential 'any' keyword with
@InjectedObject
property wrapper, the fired error is:Type 'any Test' cannot conform to 'ObservableObject'
the example is as follows:
The text was updated successfully, but these errors were encountered: