waitForIviServiceAsyncFunResult

fun <R> waitForIviServiceAsyncFunResult(timeoutMs: Long = DEFAULT_WAIT_LIVE_DATA_TIMEOUT_MS, function: ((IviServiceFunResult<R?>?) -> Unit) -> Unit): IviServiceFunResult<R?>

Utility function to wait for an IVI service async function result.

Invokes function with an onResult argument and waits for the onResult callback to be invoked by the function until timeoutMs is reached. An AssertionError is thrown when the timeout is reached.

Returns the IviServiceFunResult given to the onResult callback.

In most cases, use waitForAndCheckIviServiceAsyncFunResult instead, which extends this function with error checking. This function may be used to handle exception differently.

Prefer the use of waitForIviServiceCoFunResult over this function. As waitForIviServiceCoFunResult is able to add the function name to the thrown AssertionError exception, whereas this function is not able to add any meaningful information.

Example usage:

val tripService = createApiWrapper { TripService.createApi(...) }
val funResult = waitForIviServiceAsyncFunResult<Unit> { onResult ->
tripService.planTripToAsync(EINDHOVEN_PLACE, onResult)
}