Skip to content

Instantly share code, notes, and snippets.

@burnoo
Last active October 4, 2021 19:54
Show Gist options
  • Save burnoo/4bfb454f8bcd8618fd81f5fe07ed5659 to your computer and use it in GitHub Desktop.
Save burnoo/4bfb454f8bcd8618fd81f5fe07ed5659 to your computer and use it in GitHub Desktop.
Cokoin Medium 4
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