Neal Sanche
02/26/2021, 5:03 AMZach Klippenstein (he/him) [MOD]
02/26/2021, 5:14 AMNeal Sanche
02/26/2021, 5:28 AMval LocalImageViewModel = staticCompositionLocalOf<ImageViewModel> {
error("LocalImageViewModel value not available.")
}
and in my setContent, I've done this:
CompositionLocalProvider(LocalImageViewModel provides imageViewModel) {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.error) {
SimpleCameraPreview()
}
}
And then I can get the viewmodel wherever I need it in the composable tree. But Maybe this is not what I should be doing, and instead, maybe I should be making state out of the things inside the viewModel that need to be passed down, and just using raw data values for displaying everything.jim
02/26/2021, 3:14 PMSo it's a bit more interconnected than just simple passing data down to views.This indicates that you're not yet thinking about Compose correctly. If anything about your data flow is "more interconnected than just simple passing data down" then you're thinking about it incorrectly and should rework your data flow.
Neal Sanche
02/26/2021, 4:12 PMPreviewView
and simply just create a flow of images from the selected camera. That can live in Android land, and can be passed down into the composables. And I can also hope that CameraX gets a nice set of composable functions at some point in the future.