use Async
This hook function accepts a suspend function as a parameter and returns an function(use to execute suspend function). When you call the execution function, the suspend function will be executed within the coroutine scope of the current component.
Return
Receiver
Parameters
fn
This is a hook function that simplifies the use of coroutine scope. It holds the coroutine scope through an object to achieve a usage similar to the run function. Equivalent to scope.launch { }
val asyncRun = useAsync()
asyncRun {
// do something
}
Content copied to clipboard