I’m trying to remove channel.consumeEach from blue...
# coroutines
m
I’m trying to remove channel.consumeEach from bluetooth communication in my project. What is current best replacement for it? Should I use consumeAsFlow() and then just collect it?
t
If you're not looking to do a larger refactor to use
Flow
out of the gate, then
consumeAsFlow
(with
collect
, as you described) will work to replace your
consumeEach
usages.
m
@travis Thanks for your answer. I did like you said and it is working fine. I'm planning to migrate to Flow, but I've just upgraded from coroutines 1.3.5 to 1.3.8, so removing ConflatedBroadcastChannel will be problematic.
t
You didn't say if you are working with Bluetooth Classic or Bluetooth Low Energy, if it is Low Energy then you can look at https://github.com/JuulLabs/kable to either use, or for implementation inspiration. Disclaimer: it's a bit of a self plug, since I'm a contributor to the library.
m
@travis I'm working with Bluetooth Low Energy devices. I've already noticed your BLE library. I would consider migrating to your library because the current company solution is basing on an old version of the altbeacon library mixed with the messy implementation of encryption.
👍 1