I have something like ```when (deeplink.lastPathSe...
# koin
k
I have something like
Copy code
when (deeplink.lastPathSegment) {
    BRANCHES_SEGMENT -> presenter.loadBranches()
    else -> updateHomeState(screenState = HomeScreenState.HomeScreen)
}
the presenter is being injected on the Activity and on onStart and onCreate the presenter instance has not been initiliazed yet
a
can you show, how your
presenter
is initialized?
k
This is the Activity instance
Copy code
private val presenter: IHomeViewContract.Presenter by inject()
And this other chunk the way I defined on the module
Copy code
factory<IHomeViewContract.Presenter> { HomePresenter(resourceProvider = get(), serviceProvider = get(), analytics = get() }
It’s not crashing
t
If a lazy is not initialised, you haven’t used it before. What’s the issue with what you describe?
k
I need the instance to be there in order for the presenter to react whenever the deeplink is triggered; if is not initialized it will just skip the call
The benefits of a lazy instance is that it knows how to provide and initialize the instance on the first call; by not having the instance initialized by the inject is just avoiding the execution
a
You can try to have the
get
call in the block there you are using the presenter. Does the presenter has some long running initialization? This could be the reason why it is not there at the time you want to use it. Also this will not keep the instance until activity is being destroyed. Unless of cause, if you are using it in some other methods of your activity.
k
The presenter is injecting the values; thanks I will try with using
get
I see how it develops.
That is working 🤔
🤟 1