W3C home > Mailing lists > Public > public-device-apis-log@w3.org > September 2019

Re: [wake-lock] WakeLock.request() returns a promise that never resolves (#226)

From: Kenneth Rohde Christiansen via GitHub <sysbot+gh@w3.org>
Date: Tue, 24 Sep 2019 08:56:25 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-534462642-1569315383-sysbot+gh@w3.org>
> ```js
> let lock = await navigator.wakeLock.request("screen");
> lock.onstatechange = async ev => {
>    // request a new lock, maybe...
>    lock = await navigator.wakeLock.request(ev.lock.type); 
> }
> ```

So when the promise resolves it will have either failed or be active, but before you add the `onstatechanged` callback. That makes `onstatechanged` a bit useless, and we might as well just have a `onlockreleased` instead.

Also, can you try writing your example in a way where it integrates with visibilitychange?

-- 
GitHub Notification of comment by kenchris
Please view or discuss this issue at https://github.com/w3c/wake-lock/issues/226#issuecomment-534462642 using your GitHub account
Received on Tuesday, 24 September 2019 08:56:27 UTC

This archive was generated by hypermail 2.4.0 : Monday, 4 July 2022 12:47:56 UTC