kluck
06/17/2019, 9:01 AMIO.async() which works great for a single barcode scanning.
fun startScanning(): IO<ScanItem> = IO.async()
.async { callback: (Either<Throwable, ScanItem>) -> Unit ->
resume()
decodeContinuous(object : BarcodeCallback {
override fun possibleResultPoints(resultPoints: MutableList<ResultPoint>?) {}
override fun barcodeResult(result: BarcodeResult) {
callback(ScanItem(result.text, result.barcodeFormat.toScanItemFormat()).right())
}
})
}
// inside my activity
scanner.startScanning()
.map {
Timber.d("Scanned item: $it")
scanner.setStatusText(it.data)
}
.unsafeRunAsync { result -> result.mapLeft { Timber.e(it) } }
What is the idiomatic way to handle multiple barcode scans?