Skip to content

Notify the user when notifications are actually turned on #483

Open
@mikolak

Description

@mikolak

Modify .monitorCharacteristic() methods to accept additional callback with an argument of type Future<void>. This way the user of the library is able run logic depending on the notification being turned on.

Proposed API change:

class Peripheral {
  ...
  Stream<CharacteristicWithValue> monitorCharacteristic(
    String serviceUuid,
    String characteristicUuid, {
    String transactionId,
    void Function(Future<void>) onNotificationsTurnedOnCallback = (_) {},
  })
  ...
}

Example:

async onNotificationsTurnedOn() {
  await peripheral.writeCharacteristic(...);
}
...

peripheral.monitorCharacteristic(
  "<serviceUuid>", 
  "<characteristicUuid>", 
  onNotificationsTurnedOnCallback = async (future) { 
    await future; 
    onNotificationsTurnedOn(); 
  }).listen((value) => print(value););

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions