John O'Reilly
09/13/2020, 11:14 AMlaunchInComposition
as shown here to call suspend function....what's recommended way to show progress indicator (like CircularProgressIndicator
) until that function completes?
@Composable
fun MainLayout(sdk: SpaceXSDK) {
var launches by remember { mutableStateOf<List<RocketLaunch>>(emptyList()) }
launchInComposition {
launches = sdk.getLaunches(false)
}
LazyColumnFor(items = launches) { launch ->
LaunchView(launch)
}
}
JetNews
sample has something very similar to what I need (with their launchUiStateProducer
)Halil Ozercan
09/13/2020, 12:08 PMremember { mutableStateOf(true) }
and update that state once your calculation is completed in launchInComposition
var isLoading by remember { mutableStateOf(true) }
launchInComposition {
...
isLoading = false
}
if(isLoading) {
CircularProgressIndicator()
}
John O'Reilly
09/13/2020, 12:45 PM