Consider an API where only Streams and Sinks are exposed:
This would remove the explicit calls read and write. For instance, if you'd like to only read a value once, you can use a one-shot stream call like characteristic.value.first.
A separate branch should be created to investigate this API.
This has the added benefit of making stream transformations that much easier.
For instance, one could simply pipe the value stream's List<int> to a String converter to handle conversion automatically. Vice versa, the value's sink could be wrapped with a String converter to automatically take String input from the user and convert to List<int>. (https://github.com/pauldemarco/flutter_blue/issues/279)
@pauldemarco May some values can be ValueListenable instead of Stream ? Even if "only streams api" is attractive, for some simple values like BluetoothState or BluetoothDeviceState, ValueListenable may be lighter for the same result.
@pauldemarco May some values can be ValueListenable instead of Stream ? Even if "only streams api" is attractive, for some simple values like BluetoothState or BluetoothDeviceState, ValueListenable may be lighter for the same result.
Streams can be wrapped into a Observable and thus, receive all the benefits of rxdart transformation methods. ValueListenable, don't.
Most helpful comment
@pauldemarco May some values can be ValueListenable instead of Stream ? Even if "only streams api" is attractive, for some simple values like BluetoothState or BluetoothDeviceState, ValueListenable may be lighter for the same result.