-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
How to Register Singletons that reference other Singletons? #702
Comments
The problem here is that you do not register
Please note here,
But here is another problem, your When VContainer create your To solve this problem, you can remove the dependency of Please note, this is not the best practice, you should avoid circular dependency. Here is all the code that changed:
|
I am quite new to this Dependency Injection thing in general, so I'm sorry if the question is silly or if there is a workaround that I am not aware of.
I was trying to follow the HelloWorld example on the documentation and start using VContainer from there.
Then I had a problem, when I was registering 2 classes which implement
IStartable
and one has a reference to another. I would get a message like the following:I tried to reduce my app to a minimal setup so my trouble would be easier to understand/reproduce.
Imagine we have the following 5 scripts:
BarController
It basically takes BarView Button and OnClick, it will change the text contents of the Label of FooView through FooController
BarView
FooController
It basically takes FooView Button and OnClick, it will change the text contents of the Label of BarView through BarController
FooView
GameLifetimeScope
LifetimeScope to register components
Wiring up all the references on UnityEditor and pressing play will result in the following VContainerException:
I would really appreciate any help!
The text was updated successfully, but these errors were encountered: