zip

fun <T, R> BleResult<T>.zip(other: BleResult<R>): BleResult<Pair<T, R>>

Combines two BleResult instances into a single result containing a Pair.

If both results are successful, returns a Success containing a pair of both values. If either result is a failure, returns the first encountered Failure.

val nameResult = connection.readCharacteristicResult(serviceUuid, nameCharUuid)
val versionResult = connection.readCharacteristicResult(serviceUuid, versionCharUuid)

val combined: BleResult<Pair<ByteArray, ByteArray>> = nameResult.zip(versionResult)
combined.onSuccess { (name, version) ->
Log.i("BLE", "Device: ${String(name)}, Version: ${String(version)}")
}

Return

A BleResult containing a Pair of both values, or the first failure.

Parameters

other

The other BleResult to combine with.