useAsync

fun useAsync(fn: SuspendAsyncFn): () -> Unit

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

fun useAsync(): AsyncRunFn

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
}

Return