diff --git a/packages/flutter_reactive_ble/lib/src/reactive_ble.dart b/packages/flutter_reactive_ble/lib/src/reactive_ble.dart index 94f1188c..cc1fd9bf 100644 --- a/packages/flutter_reactive_ble/lib/src/reactive_ble.dart +++ b/packages/flutter_reactive_ble/lib/src/reactive_ble.dart @@ -60,11 +60,10 @@ class FlutterReactiveBle { BleStatus get status => _status; /// A stream providing connection updates for all the connected BLE devices. - Stream get connectedDeviceStream => Repeater(onListenEmitFrom: () async* { + Stream get connectedDeviceStream => Repeater.broadcast(onListenEmitFrom: () async* { await initialize(); yield* _deviceConnector.deviceConnectionStateUpdateStream; - }).stream.asBroadcastStream() - ..listen((_) {}); + }).stream; /// A stream providing value updates for all the connected BLE devices. /// @@ -105,8 +104,7 @@ class FlutterReactiveBle { ); if (Platform.isAndroid || Platform.isIOS) { - ReactiveBlePlatform.instance = - const ReactiveBleMobilePlatformFactory().create( + ReactiveBlePlatform.instance = const ReactiveBleMobilePlatformFactory().create( logger: _debugLogger, ); } @@ -398,11 +396,10 @@ class FlutterReactiveBle { Future clearGattCache(String deviceId) => _blePlatform.clearGattCache(deviceId).then((info) => info.dematerialize()); - /// Reads the RSSI of the of the peripheral with the given device ID. + /// Reads the RSSI of the of the peripheral with the given device ID. /// The peripheral must be connected, otherwise a [PlatformException] will be /// thrown - Future readRssi(String deviceId) async => - _blePlatform.readRssi(deviceId); + Future readRssi(String deviceId) async => _blePlatform.readRssi(deviceId); /// Subscribes to updates from the characteristic specified. ///