What’s the right way to add compose state into a k...
# koin
r
What’s the right way to add compose state into a koin graph? My use-case is, I have an operation that needs to be able to request location permission, so I use
rememberLauncherForActivityResult()
and wrap it into an interface that I want to pass into koin. Right now I’m loading a module and a scope inside a `DisposableEffect`:
Copy code
val locationPermissionRequester = rememberLocationPermissionRequester()
    val koin = getKoin()
    val scopeState = remember { mutableStateOf<Scope?>(null) }

    DisposableEffect(koin, locationPermissionRequester) {
        val module = module {
            scope(koinUiScopeQualifier) {
                scoped { locationPermissionRequester }
            }
        }
        val scope = koin.createScope(composeScopeId, koinUiScopeQualifier)
        scopeState.value = scope

        koin.loadModules(listOf(module))
        onDispose {
            scope.close()
            koin.unloadModules(listOf(module))
        }
    }
Then, my UI null-checks
scopeState.value
before grabbing its dependencies via
scopeState.value.get()
. Is that a reasonable approach? Did I overthink this? Am I missing any details?