You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I had this problem when creating more advanced MVP example.
Sometimes you need to pass activity (which is scope owner) to for example UseCase.
Now you're forced not to use constructor injection, because you can't easily define injection of this activity.
Describe the solution you'd like
The best idea (which @arnaudgiuliani told me on slack!) would be to make a method inside scope addInstance() and just pass whatever it is inside scope, to be available with simple get().
This instance would have the same lifecycle as whole scope, to prevent leaks.
Describe alternatives you've considered
I've tried to use injection parameters, but this forces you to inject everything using lazy methods instead of constructors. In simplest case you end up with something like that:
Is your feature request related to a problem? Please describe.
I had this problem when creating more advanced MVP example.
Sometimes you need to pass activity (which is scope owner) to for example UseCase.
Now you're forced not to use constructor injection, because you can't easily define injection of this activity.
Describe the solution you'd like
The best idea (which @arnaudgiuliani told me on slack!) would be to make a method inside scope
addInstance()
and just pass whatever it is inside scope, to be available with simple get().This instance would have the same lifecycle as whole scope, to prevent leaks.
Describe alternatives you've considered
I've tried to use injection parameters, but this forces you to inject everything using lazy methods instead of constructors. In simplest case you end up with something like that:
Target Koin project
koin-core
The text was updated successfully, but these errors were encountered: