Hi <@U2JKKPMEE>, my I ask a question. I found thi...
# koin
a
Hi @arnaud.giuliani, my I ask a question. I found this in the documentation:
Copy code
class Presenter(val view : MyViewContract)

val androidModule = module {

    scope<MyActivity> {
        // inject current MyActivity
        scoped { Presenter(get()) }
    }
}
since the
activityScope()
is backed inside the
ViewModel
:
Copy code
// Create Activity scope (backed by ViewModel)
override val scope: Scope by lazy { activityScope() }
And the presenter have the reference of the
View
wouldn't this leak the
Activity
? If I understand it correctly, since the
scope
is backed inside a
ViewModel
the same instance of
Presenter
will be provided when the
Activity
did some configuration changes (such as device rotation)... The Activity will be destroyed with its views and a new Activity will be created but.. the presenter is still holding the instance of the destroyed view (View of the Old Activity)... I am really confuse.
a
yes, this is a current limitation. Best for Presenter is to override current scope with
newScope()
2.2.1 with
activityScope()
don’t keep source anymore
viewModel holder is closing on end of activity
Hilt introduced
activityScope
and
activityRetrainedScope
a
I see then, there will also be a
activityRetrainedScope
in koin as well?
a
yes, I think it can be interesting to clearly make the distinguish
❤️ 2
a
Awesome! May I ask another question? Shouldn't Scoped Dependencies defined in
ScopedActivity
also be available inside
ScopedFragment
?
a
yes we could do
❤️ 1
a
Alright thank you very much!
👍 1