W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2014

Re: Ambient light API redesign

From: Kostiainen, Anssi <anssi.kostiainen@intel.com>
Date: Tue, 26 Aug 2014 11:46:58 +0000
To: Anne van Kesteren <annevk@annevk.nl>
CC: public-script-coord <public-script-coord@w3.org>, "public-device-apis@w3.org" <public-device-apis@w3.org>, Doug Turner <dougt@mozilla.com>, Rick Waldron <waldron.rick@gmail.com>
Message-ID: <1BFBFF5F-34C8-4BB7-A537-D29ECC8F60D1@intel.com>
On 26 Aug 2014, at 12:43, Anne van Kesteren <annevk@annevk.nl> wrote:

> In https://bugzilla.mozilla.org/show_bug.cgi?id=1057185 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.

Thanks,

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:22 UTC