-
-
Notifications
You must be signed in to change notification settings - Fork 153
[Question] How do I change singleton in runtime, replacing it in all dependent instances? #259
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
Comments
First I always find it funny seeing people combine get_it with Provider and then even with Bloc? did you ever check out my get_it_mixin? But to your question: I don't understand why you think it would be a problem with dependent classes. If you AppBloc accesses API only over the |
I don't see anything funny actually in combining get_it with any other kind of state management. In my example it could be any other class I think. I've created this question because I've tried to implement mentioned behaviour just as I described in the question. I'm using |
Sorry, I didn't want to insult you. If you don't want call |
I know several people combining get_it with other state management solutions. But IMHO using three as in your case is a bit of an overkill. you are using provider as it looks like just as another service locator which could also be done by get_it |
Don't worry, i didn't think that was an insult, just a misunderstanding and I understand why now. I don't use Provider, Regarding the question, I don't know why, but I thought that maybe there's some magic way to do that. I see that making field mutable is the best way to do so, but there's restrictions imposed by "retrofit" that generated |
@Tumist76 did you find the solution for this? I tried to make an global variable as a mutation field, but getIt still returns the old singleton instance. |
Uh oh!
There was an error while loading. Please reload this page.
Let's say I have the following setup in my app:
Somewhere in the app I use that singleton like this:
In the app lifecycle I need to re-create with singleton with another
baseUrl
and that's not a problem withunregister()
and then callingregisterSingleton
again but how dependent classes can I use this new singleton?Is it possible to make new instance of
Api
class and make dependent class instance (AppBloc
in this case) to use that newApi
without recreatingAppBloc
?The text was updated successfully, but these errors were encountered: