Conversation
Expose the browser Screen Wake Lock API through Page methods, allowing server-side Java code to prevent the screen from dimming or locking for dashboards, kiosks, and presentations.
|
| * listeners registered with {@link #addWakeLockReleaseListener} are | ||
| * notified. | ||
| */ | ||
| public void requestWakeLock() { |
There was a problem hiding this comment.
It would be good to have a way to be notified in case of error; for example, an optional callback parameter to be chained to the pending JS invocation. Or return a CompletableFuture
| public PendingJavaScriptResult isWakeLockActive() { | ||
| return executeJs("return window.Vaadin.Flow.wakeLock.isActive()"); | ||
| } |
There was a problem hiding this comment.
What about a typed callback parameter instead of returning PendingJavaScriptResult? Or return a CompletableFuture<Boolean>?
| if (sentinel !== null) { | ||
| return; | ||
| } | ||
| sentinel = await navigator.wakeLock.request('screen'); |
There was a problem hiding this comment.
It would be good to propagate errors to the server so that the developers can immediately react on them, instead of having to do another call to isActive.
There was a problem hiding this comment.
Only errors or lock release events? I think 'release' events can go to server too.
There was a problem hiding this comment.
I don't know if the following code has been added after your comment, but there is a release listener forwarding the event to the server.



Expose the browser Screen Wake Lock API through Page methods, allowing server-side Java code to prevent the screen from dimming or locking for dashboards, kiosks, and presentations.