Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] Android/Koin – How to tell koin that a single dependency should be reinitialized

Posted on November 14, 2022

Solution 1 :

After doing A LOT OF RESEARCH, I found this post on GitHub scoping is the solution for my problem.

— OR —

using

unloadKoinModules(networkModule)
loadKoinModules(networkModule)

and then get the instance again:

val api: InstanceApi = getKoin().get()

Problem :

I stumbled across a problem where I have to reinitialize my Retrofit API class because the URL changes, so I want to tell Koin to reinitialize the single dependency. I don’t want to use factory because it is still a singleton most of the time.

Stopping and starting koin would be an idea but that is a very heavy and time intense prozess so I don’t want to do that.

any ideas?

Comments

Comment posted by Rinat Diushenov

why don’t you create 2 instances with 2 different base urls?

Comment posted by kaulex

The problem is that this case can happen more often then 2 times so I would need to create a new retrofit instance every time I use it. SO I thought about solving it in koin, to recreate only one single dependency

Comment posted by ivan8m8

But the isuue author wrote about a leak. Do you consider that?

Comment posted by kaulex

I just mentioned the issue because it is providing the solution. It is not the same issue I had. Never had problems with the solution here.

READ  [ANSWERED] android studio - How can i trace eating with mouth closed using Google ML Kit
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress