Hi, I'm trying to find the correct abstraction for...
# arrow
k
Hi, I'm trying to find the correct abstraction for continuously decoding barcodes. I'm currently using
IO.async()
which works great for a single barcode scanning.
Copy code
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?