gsala
02/17/2020, 8:24 AMfun connect(bluetoothDevice: BluetoothDevice) : Observable<RxBleConnection>
. The reason this returns an Observable
instead of a Single
is that the life-cycle of the Observable
is tied to the connection. So this observable will only ever emit one item, but it will stay alive without completing so the connection stays alive until we dispose.
I want to wrap this to use coroutines instead.
I'm thinking about having a function like suspend fun connect(bluetoothDevice : BluetoothDevice) : RxBleConnection
,
Any ideas on how to handle the life-cycle of the Observable? If I just use connectObservable.awaitFirst()
it will take the first value, and dispose, which will stop the connection.kioba
02/17/2020, 9:07 AMgsala
02/17/2020, 9:17 AMkioba
02/17/2020, 9:19 AM