[web-bluetooth] Observing characteristic notifications start and stop

rajsite has just created a new issue for https://github.com/WebBluetoothCG/web-bluetooth:

== Observing characteristic notifications start and stop ==
The startNotifications and stopNotifications effect all event listeners for a characteristic.

I have an event listener that closes around some state for buffering messages that come in. When notifications stop I want to be able to clean-up that state which involves resolving some pending promises.

As is some external factor can call stopNotifications or startNotifications and I don't see a native way to observe that change.

Some ideas:
1. Add event listeners for gatt characteristic value change notifications starting and stopping
2. Implement `characteristic.getNotifier` returns a reference to a GATTCharacteristicNotifier object that I use for registering event listeners instead of registering on the characteristic. I can start and stop notifications on the GATTCharactertisticNotifier instance without impacting other observers (and them impacting me)
3. Maybe not have startNotifications and stopNotifications? There is no equivalent parallel in the DOM space for disabling the event system. Seems like this idea has been previously rejected: https://github.com/WebBluetoothCG/web-bluetooth/issues/236

Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/408 using your GitHub account

Received on Tuesday, 4 September 2018 05:56:45 UTC