Was just quickly trying out new `KoinApplicationPr...
# koin
j
Was just quickly trying out new
KoinApplicationPreview
in 4.1.....should something like following work? I'm getting render issue as soon as I add the `koinViewModel`but I could be missing something else perhaps
Copy code
@Preview
@Composable
fun PreviewPlayerListView() {
    KoinApplicationPreview(application = { modules(appModule, commonModule(false)) }) {
        SomeComposable()
    }
}

@Composable
fun SomeComposable() {
    val playerListViewModel = koinViewModel<PlayerListViewModel>()
    Text("hey there")
}
the issue shown then is
Copy code
Failed to instantiate a ViewModel
if I change to say
Copy code
@Composable
fun SomeComposable() {
    val repo = koinInject<FantasyPremierLeagueRepository>()
    Text("hey there")
}
then the render issue shown is
Copy code
Failed to instantiate Composition Local
a
you are using
koinInject
here?
j
in 2nd case I am....using
koinViewModel
in first case
I'll create a branch later with the changes
it was in this project fwiw .....added that code as test to top of
PlayersListView.kt
perhaps some issue with combination of dependencies I have
a
do you have stack?
j
this is just error shown in AS when it's trying to show preview.....didn't see any stack (just messages mentioned above).....there might be some other logs somewhere that have them....will check later
Also using AS beta fwiw (Narwhal RC version)
a
ha ok
do you have a branch that I can checkout?
j
I'll create one in a short while
a
thx 🙏
j
sorry, got side tracked....will hopefully get chance later
again, could likely be something wrong with my setup
m
Did you check the AS logs
Help / Show Log in Finder
?
j
meant to look there that time but got side tracked again! This is what I see.
Copy code
java.lang.IllegalStateException: KoinApplication has not been started
	at org.koin.core.context.GlobalContext.get(GlobalContext.kt:36)
	at org.koin.core.component.KoinComponent$DefaultImpls.getKoin(KoinComponent.kt:33)
	at dev.johnoreilly.common.data.repository.FantasyPremierLeagueRepository.getKoin(FantasyPremierLeagueRepository.kt:27)
a
do you have something calling Koin before ? @John O'Reilly
j
This is just this preview
a
You have something calling Koin via KoinComponent, can you look at it? seems to be
FantasyPremierLeagueRepository
?
j
Is that not happening within
KoinApplicationPreview
?
oh, I think I see what you mean
so, both
KoinApplicationPreview
and
KoinComponent
are trying to init koin?
a
yes
arf ... I see your point. KoinApplicationPreview is using local Koin context, not global one 😕
KoinComponent try to look in Global context, where KoinApplicationPreview run local ones
to allow parallel rendering
else use KoinApplication preview