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

On Mon, Aug 25, 2014 at 11:55 AM, Marcos Caceres <> 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:

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();
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