Last active
October 4, 2021 19:54
-
-
Save burnoo/4bfb454f8bcd8618fd81f5fe07ed5659 to your computer and use it in GitHub Desktop.
Cokoin Medium 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class A(val value: String) | |
val scopedModule = module { | |
scope<ScopeTypeA> { | |
scoped { A("scopeA") } | |
} | |
scope<ScopeTypeB> { | |
scoped { A("scopeB") } | |
} | |
} | |
@Preview | |
@Composable | |
fun App() { | |
Koin(appDeclaration = { modules(scopedModule) }) { | |
Column { | |
KoinScope(getScope = { createScope<ScopeTypeA>() }) { | |
Text(get<A>().value) | |
} | |
KoinScope(getScope = { createScope<ScopeTypeB>() }) { | |
Text(get<A>().value) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment