Thread
#compose
    John O'Reilly

    John O'Reilly

    2 years ago
    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?
    @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
    )
    Halil Ozercan

    Halil Ozercan

    2 years ago
    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
    something like
    var isLoading by remember { mutableStateOf(true) }
    
    launchInComposition { 
       ...
       isLoading = false
    }
    
    if(isLoading) {
        CircularProgressIndicator()
    }