Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes subscription to _deviceConnector.deviceConnectionStateUpdateStream leaking #876

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions packages/flutter_reactive_ble/lib/src/reactive_ble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ class FlutterReactiveBle {
BleStatus get status => _status;

/// A stream providing connection updates for all the connected BLE devices.
Stream<ConnectionStateUpdate> get connectedDeviceStream => Repeater(onListenEmitFrom: () async* {
Stream<ConnectionStateUpdate> 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.
///
Expand Down Expand Up @@ -105,8 +104,7 @@ class FlutterReactiveBle {
);

if (Platform.isAndroid || Platform.isIOS) {
ReactiveBlePlatform.instance =
const ReactiveBleMobilePlatformFactory().create(
ReactiveBlePlatform.instance = const ReactiveBleMobilePlatformFactory().create(
logger: _debugLogger,
);
}
Expand Down Expand Up @@ -398,11 +396,10 @@ class FlutterReactiveBle {
Future<void> 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<int> readRssi(String deviceId) async =>
_blePlatform.readRssi(deviceId);
Future<int> readRssi(String deviceId) async => _blePlatform.readRssi(deviceId);

/// Subscribes to updates from the characteristic specified.
///
Expand Down
Loading