-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example usage of onrelease event. #250
Comments
Isn't that covered by example 2, which has navigator.wakeLock.request("screen").then(lock => {
checkbox.checked = true;
const listener = (ev) => {
checkbox.checked = false;
ev.target.removeEventListener('release', listener);
};
lock.addEventListener('release', listener);
}); ? |
We should |
(@rakuco you are correct is what I mean - but could be clearer) |
How about this: const sentinel = await navigator.wakeLock.request('screen');
checkbox.checked = true;
const listener = (ev) => {
checkbox.checked = false;
ev.target.remoteEventListener('release', listener);
};
sentinel.onrelease = listener; (not sure whether it's clearer to use |
I like it :) @scheib, wdyt? Would that be clearer? We should also make sure we have a link to the relevant example. |
First, I apologize having overlooked that there was an example. I looked adjacent to the release event definition, and searched the page for 'onrelease', and didn't take the time to find example 2. I do like the rework. Using 'onrelease' will help others who make my mistake. As would having the example linked or moved to be in context. Also, might keep it even simpler by directly assigning the function and not de-registering it. Focusing just on what's needed to demonstrate the spec:
Are there any other things we expect apps to do when lock is lost? Attempt to reacquire? That's blocked because user activation is needed. Any other possible action other than just notifying the user in UI that lock is lost? |
Simplify it a little but, use `await` instead of `.then()`. Also replace `addEventListener()` with a direct assignment of the `onrelease` attribute to make the example easier to find. Fixes w3c#250.
#251 updates the example and hopefully makes it easier to find and understand.
Note that user activation is needed only when a UA sets the permission to "prompt". The Chromium implementation, for example, always grants screen wake locks regardless of whether the request was triggered by user activation or not. |
Simplify it a little but, use `await` instead of `.then()`. Also replace `addEventListener()` with a direct assignment of the `onrelease` attribute to make the example easier to find. Fixes w3c#250.
Simplify it a little but, use `await` instead of `.then()`. Also replace `addEventListener()` with a direct assignment of the `onrelease` attribute to make the example easier to find. Fixes w3c#250.
Simplify it a little but, use `await` instead of `.then()`. Also replace `addEventListener()` with a direct assignment of the `onrelease` attribute to make the example easier to find. Fixes #250.
The WakeLockSentinel onrelease event is "used to notify scripts that a given WakeLockSentinel object's handle has been released, either due to the release() method being called or because the wake lock was released by the user agent."
For spec readability it would help to have usage examples.
The text was updated successfully, but these errors were encountered: