Trying to integrate 2.2.0-beta-3 into my project a...
# koin
a
Trying to integrate 2.2.0-beta-3 into my project and interesting if activity is subclass of
ScopeActivity
and has field defined like this
Copy code
private val splashVM by scope.viewModel<SplashViewModel>()
it failed with
Caused by: java.lang.IllegalStateException: Your activity is not yet attached to the Application instance. You can't request ViewModel before onCreate call.
Am I understand incorrectly that
by scope.viewModel
should be called only while I’m calling
splashVM
somewhere later in my code? And I only calling
splashVM
inside
onCreate
but for some reason it still failed and seems to call scope right away on activity init method call. @arnaud.giuliani should I use it somehow differently now?
a
There is already extensions to help use that in rc-3
subclassing with KoinScopeComponent like ScopeActivity allow to have get,inject,getViewModel using directly the linked scope
no need to explicitly use
scope.get
or other injection, as we are doing it or you
a
oh, yah… I can just remove
scope
.
also noticed that Android Studio has some issues to offer correct import for
viewModel
and
getViewModel
extensions. At least the canary 15.
a
perhaps yes 🤔