wrapWithCallback

fun <T> wrapWithCallback(scope: CoroutineScope, callback: (Result<T>) -> Unit, block: suspend () -> T)

Wraps a suspend function with a callback, allowing for safe, asynchronous handling of results or exceptions in a coroutine.

Parameters

scope

The coroutine scope in which the function should be executed.

callback

The callback that receives the result or an error.

block

The suspend function to execute.