subscribe method

  1. @override
Stream<Uint8List> subscribe(
  1. Uuid service,
  2. Uuid characteristic
)
override

Enables notifications/indications on characteristic and streams the values the peripheral pushes. Cancelling the subscription disables them.

Implementation

@override
Stream<Uint8List> subscribe(Uuid service, Uuid characteristic) {
  final err = subscribeError;
  if (err != null) throw err;
  final c = _notify.putIfAbsent(
    characteristic,
    () => StreamController<Uint8List>.broadcast(
      onListen: () => notifyEnabled[characteristic] = true,
      onCancel: () => notifyEnabled[characteristic] = false,
    ),
  );
  return c.stream;
}