Marcin Środa
08/11/2020, 8:17 AM@Preview
now. Any ideas how to achive it? My goal is to create a standalone component based on custom library / framework with defined fetching messages or something 🙂Joost Klitsie
08/11/2020, 8:32 AM@Composable
fun myComposable() {
val viewModel = // fetch viewModel
val state = viewModel.viewState.collectAsState()
myActualComposable(state)
}
@Composable
fun myActualComposable(state: MyViewState) {
// compose stuff
}
@Preview
@Composable
fun previewComposable() {
val viewState = MyViewState(
// view state stuff like:
text = "text",
showError = false)
myActualComposable(viewState)
}
I am guessing that injection/getting viewmodel from the activity view model store is a tad difficult in preview mode as there is no actual running framework to deliver you the goodsMarcin Środa
08/11/2020, 8:49 AMflosch
08/11/2020, 10:44 AM