Suppose I have a `SystemUiTools` interface (and im...
# compose
m
Suppose I have a
SystemUiTools
interface (and implemented with
AndroidSystemUiTools(Context)
implementation (
Context
provided using
LocalContext.current
) used throughout the compose code. How to decide whether to make it available via
staticCompositionLocalOf()
(i.e.
LocalSystemUiTools.current
) vs.
Copy code
@Composable
fun rememberSystemUiTools(): SystemUiTools {
    val context = LocalContext.current
    return remember(context) {
        AndroidSystemUiTools(context)
    }
}
Note: this is an Android app for now, but I’m refactoring with a look to keeping Android-specific parts separate.
I guess using the
CompositionLocalProvider
solution allows proper testing?