[web-bluetooth] readValue()'s event and Promise handlers should execute in an order matching the spec

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

== readValue()'s event and Promise handlers should execute in an order
 matching the spec ==
[readValue()](https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothgattcharacteristic-readvalue)
 queues a task to:

1. Resolve a promise and
1. Fire an event.

The promise's `.then()` handlers run on the microtask loop, but [event
 dispatching](https://dom.spec.whatwg.org/#concept-event-dispatch) 
happens synchronously, leading to an order of operations that's not 
clear from the spec. We should either reverse the order in the spec or
 queue another task for the event to make sure it happens after the 
promise.

I'm inclined to queue another task, although that does open the 
possibility that multiple readValue() calls will complete, and the 
intermediate values won't be reflected during any event handlers.

See https://github.com/WebBluetoothCG/web-bluetooth/issues/175

Received on Thursday, 15 October 2015 21:46:15 UTC