adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.27k stars 109 forks source link

Koin 3.6.0 Wasm support #359

Open Shusshu opened 2 months ago

Shusshu commented 2 months ago

Koin support WASM as of version 3.6.0 currently in alpha.

DevSrSouza commented 2 months ago

I think we should wait until Koin stable release, if someone wants to try Koin and Voyager.

Copying this two functions should be enough:

@Composable
public inline fun <reified T : ScreenModel> Screen.getScreenModel(
    qualifier: Qualifier? = null,
    noinline parameters: ParametersDefinition? = null
): T {
    val koin = getKoin()
    return rememberScreenModel(tag = qualifier?.value) { koin.get(qualifier, parameters) }
}

@Composable
public inline fun <reified T : ScreenModel> Navigator.getNavigatorScreenModel(
    qualifier: Qualifier? = null,
    noinline parameters: ParametersDefinition? = null
): T {
    val koin = getKoin()
    return rememberNavigatorScreenModel(tag = qualifier?.value) { koin.get(qualifier, parameters) }
}