Hello friends! Does anybody knows how to scope obj...
# koin
c
Hello friends! Does anybody knows how to scope objects to the viewmode lifecycle? I have the following "issue" where my mapper object is created twice... I was looking for an option like @Installin(ViewModelComponent::class) does in dagger-hilt but im unable to find it. https://github.com/InsertKoinIO/koin/issues/1080
a
did you tried with Scope API?
you can define a scope for your fragment within your module and it will hold definitions within that space
đź‘€ 1
c
Hello Arnauld! Thanks for your response. If I scope those objects to my fragment, wouldn't they leak if I rotate my screen? The fragment would get recreated, but, the previous created objects whitin its scope wouldnt be able to be delteted by the GC due to they are used in viewmodel, which can survive config changes? Or am I getting something wrong?
a
Yes your VM will hold instances linked to it, until it will be dropped
c
Then scope the objects to the fragment wouldnt work because they could potentially leak
So... what could be an alternative to @Installin(ViewModelComponent::class)?