https://kotlinlang.org logo
#compose
Title
# compose
j

John O'Reilly

09/13/2020, 11:14 AM
I'm using
launchInComposition
as shown here to call suspend function....what's recommended way to show progress indicator (like
CircularProgressIndicator
) until that function completes?
Copy code
@Composable
fun MainLayout(sdk: SpaceXSDK) {
    var launches by remember { mutableStateOf<List<RocketLaunch>>(emptyList()) }

    launchInComposition {
        launches = sdk.getLaunches(false)
    }
    
    LazyColumnFor(items = launches) { launch ->
        LaunchView(launch)
    }
}
actually looks like
JetNews
sample has something very similar to what I need (with their
launchUiStateProducer
)
👍 1
h

Halil Ozercan

09/13/2020, 12:08 PM
if you are looking for a really simple solution, you can always add a
remember { mutableStateOf(true) }
and update that state once your calculation is completed in
launchInComposition
👍 1
something like
Copy code
var isLoading by remember { mutableStateOf(true) }

launchInComposition { 
   ...
   isLoading = false
}

if(isLoading) {
    CircularProgressIndicator()
}
☝️ 1