https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

Souhail Marghabi

05/29/2020, 5:40 AM
Hello everyone i am currently using channels to handle one time Bluetooth BLE messaging. I have one issue where i use a conflated channel to produce emit only the last updated value. I want to reset/clear the last known value in the channel when the Bluetooth pairing process is done, and i cant seem to find how to reset stored by Channel(.CONFLATED). Any ideas how to do this?
a

allan.conda

05/29/2020, 5:58 AM
you can broadcast a state class instead of the value
Copy code
sealed class BluetoothState {
   object Idle : BluetoothState()
   data class BluetoothState(data: T) : BluetoothState()
}
// reset somewhere
channel.send(BluetoothState.Idle)
👍 1
you can’t reset it unless you make a new instance afaik
3 Views