- From: François Beaufort via GitHub <sysbot+gh@w3.org>
- Date: Thu, 06 Dec 2018 13:26:13 +0000
- To: public-device-apis-log@w3.org
beaufortfrancois has just created a new issue for https://github.com/w3c/wake-lock:
== Remove cancel() ==
Snippet below makes me wonder if we should simply cancel the wakeLockRequest when it is destroyed or garbage collected instead of forcing user to call `cancel()` and destroy it manually after.
```js
let wakeLockRequest;
function toggleWakeLock() {
if (wakeLockRequest) {
wakeLockRequest.cancel();
wakeLockRequest = null;
return;
}
wakeLockRequest = wakeLockObj.createRequest();
}
```
I'm sure there is a reason why it was thought this way and I'd love to hear it.
Code would be simpler:
```js
let wakeLockRequest;
function toggleWakeLock() {
if (wakeLockRequest) {
// Cancel wake lock request.
wakeLockRequest = null;
return;
}
wakeLockRequest = wakeLockObj.createRequest();
}
```
Please view or discuss this issue at https://github.com/w3c/wake-lock/issues/134 using your GitHub account
Received on Thursday, 6 December 2018 13:26:18 UTC