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
val scope = getKoinScope() will be called immediately.
There is a project in which each fragment implements the KoinComponent interface as follows
override fun getKoin(): Koin {
return if (parentFragment is KoinComponent) (parentFragment as KoinComponent).getKoin() else GlobalContext.get()
}
In the fragment constructor, when val ViewModel: AbcdeViewModel by ViewModel() is called, the fragment does not have a parent yet. And by viewModel is always called using GlobalContext
Expected behavior
All code in Fragment.viewModel method is executed lazy.
Bug description
Previously (koin 3.1.2), when
val viewModel: AbcdeViewModel by viewModel()
was written, all the code was executed lazy.In the current version (3.2.0), if we look at the source code, we will see that part of the code is executed immediately:
val scope = getKoinScope()
will be called immediately.There is a project in which each fragment implements the KoinComponent interface as follows
In the fragment constructor, when
val ViewModel: AbcdeViewModel by ViewModel()
is called, the fragment does not have a parent yet. Andby viewModel
is always called using GlobalContextExpected behavior
All code in Fragment.viewModel method is executed lazy.
Used koin version:
koin 3.2.0
Workaround
Something like this
The text was updated successfully, but these errors were encountered: