Which approach would you chose for asynchronous operations in compose - ones that might spawn some process and wait for the result - a coroutine or a callback? I see more and more coroutines here, but e.g. activity launcher still uses callback approach and I wonder if it's just a matter of taste or is there something that coroutine approach wouldn't handle well.
Examples
#1 callback
Copy code
val myState = rememberMyState{ result ->
//handle the result
}
//e.g. in button on click
myState.launch()
#2 coroutine
Copy code
val scope = rememberCoroutineScope()
//e.g. in button on click
scope.launch {
val result = MyState().result() //launches external process and awaits its completion
//handle the result
}
I am kinda drawn to the second approach, even considering wrapping some higher-level rememberLauncherForActivityResult into it. Wdyt?