W3C home > Mailing lists > Public > public-device-apis@w3.org > July 2014

[battery] getBattery() vs. requestBattery() pattern

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Tue, 1 Jul 2014 20:54:18 +0000
To: "public-device-apis@w3.org" <public-device-apis@w3.org>
CC: Alex Russell <slightlyoff@google.com>
Message-ID: <1404248059687.10249@domenicdenicola.com>
The spec says

> The user agent SHOULD NOT reject the promise returned by getBattery(). If the user agent does not want to expose the battery information to the web page, it is RECOMMENDED to not expose getBattery() or resolve the promise with an instance of BatteryManager exposing only default values.

I think there has been an increasing push to make APIs use a requestAccessToX().then(gotAccess, didntGetAccess) style. Alex, CC'ed, has some reasons why this is a good pattern in general; if I recall they are around how it enables a better permissions model for apps. (I hope he can explain better.)

But just from a consistency point of view, it would make more sense to me to converge.

I realize that the default values idea might have been a result of a previous discussion that I missed, and would be happy to be pointed toward it. The "not expose getBattery()" part is kind of funny, as the spec is RECOMMENDing that implementations not comply with the spec :P
Received on Tuesday, 1 July 2014 20:55:02 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 14:54:03 UTC