Re: Ambient light API redesign

On 26 Aug 2014, at 12:43, Anne van Kesteren <> wrote:

> In we discovered
> that the current API for  ambient lights is lacking and would require
> hacks to addEventListener() to salvage. Since the API is not widely
> adopted (only by Firefox per caniuse) we'd rather come up with a
> better solution. Perhaps even establishing a pattern for how we should
> expose hardware sensors to the web.
> Perhaps something like this:
>  var as = new AmbientSensor()
>  var currentVal = await as.value
>  as.onvaluechange = ...
> as long as you have a reference to the object or the object has a
> listener attached it cannot be GC'd.

Anne - thanks for the concrete proposal. IIRC we had a similar proposal on the table in the past (perhaps from Rick?), but at that time we did not have async ES sugar, thus good to revisit this discussion.

How far are we in terms of getting the needed language-level improvements in ES? I guess await and friends is a ES7 feature?

Personally I think we should try to improve the API along the lines of Annes proposal, which is more forward-looking and fixes the known issue. Also, this proposal supports N number of sensors of the same type (we can pass arguments to the constructor) -- something that the current API cannot do.

Re Chromium/Blink implementation, an intent to implement was sent a while ago and the implementation is mostly done. However, the backend code should be reusable if we were to change the API.

Id be happy to update the spec if we hear no concerns, and work with our folks who are implementing to revise the implementation too. Process-wise, weve planning to go to CR, so should we move forward with this redesign, we should postpone not to confuse people.



Received on Tuesday, 26 August 2014 11:48:23 UTC