Hi there, I was wondering if it is possible to ret...
# koin
s
Hi there, I was wondering if it is possible to retrieve a dependency tied to the scope of an activity lifecycle in a fragment (hosted by the activity of course) without using a named scope Say I declare a scope this way:
Copy code
val androidModule = module {

    scope<MyActivity> {
        scoped { Presenter() }
    }
}
and I need to retrieve the
Presenter
dependency in a fragment, which API can I use?
a
in fragment you can use
Copy code
requireActivity().currentScope.get<Presenter>()
This should return you scoped instance
👍 1
Note, that if you want to initialize a variable inside fragment you must use
lazy
initialization, since activity isn't available inside fragment right away.