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

Re: Wake Lock API as [Observable] candidate, Re: [whatwg] Object.observe()able properties on the web platform

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 25 Aug 2014 14:26:49 -0700
Message-ID: <CA+c2ei_eWM_xzqrUZtu-PEkULeU9ESegxofij4iES9g80X2iUQ@mail.gmail.com>
To: Marcos Caceres <w3c@marcosc.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Mon, Aug 25, 2014 at 11:55 AM, Marcos Caceres <w3c@marcosc.com> wrote:
>
> ```
> document.keepScreenOn = true;
> ```
>
> Versus, say:
>
> ```
> window.WakeLock.keepScreenOn = true;
> ```
>
> Your guidance would be much appreciated.

The first problem, like you mention is that the API needs to be
asynchronous. This to enable things like policies that involve user
UI, or policies that require slow processing like IPC.

So something like:

document.requestScreenOn();
Object.observe(document, myHandler, ["screenLockedOn"]);

would be better. Where document.screenLockedOn is a readonly property
which changes to 'true' any time the lock is actually granted, rather
than just requested.


The second problem with the above is that it makes it very hard for
components on a webpage to cooperate about keeping the screen on.

If this is a use case that we at all care about then I think we need
something better. For example something like:

x = new ScreenWakeLock();
x.request();
object.observe(x, myHandler, ["lockGranted"]);

would make it much easier for separate components on a page to not
stomp on each other's locks.

/ Jonas
Received on Monday, 25 August 2014 21:27:46 UTC

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