feat: add UI.triggerAfter for deferred server-side callbacks#24538
Open
Artur- wants to merge 1 commit into
Open
feat: add UI.triggerAfter for deferred server-side callbacks#24538Artur- wants to merge 1 commit into
Artur- wants to merge 1 commit into
Conversation
Member
Author
|
Use case this this feature would be at least:
button.setText("Copied"); UI.getCurrentOrThrow().runAfter(Duration.ofSeconds(1), () -> button.setText("Copy")})
// 0 still forces a client round trip
UI.getCurrentOrThrow().runAfter(Duration.ofSeconds(0), () -> { doHeavyInit();}) |
Member
|
The core of the implementation looks sensible but I have to prioritize other work this week so I won't do a thorough review of the tests and the documentation. |
Add UI.triggerAfter(Duration, SerializableRunnable), which runs a task on the server once the given delay has elapsed. The delay is measured by the browser via a one-shot client timer that makes a normal round trip when it elapses, so a single deferred event can be handled without enabling push. This change: - adds UI.triggerAfter, a facade that wires the trigger and action and returns a Registration; removing it clears the client timer, so a task cancelled before its delay elapses does not run; - adds TimeoutTrigger, which arms a one-shot setTimeout on the host element and clears it on removal; - extends CallbackAction with a value-less constructor (SerializableRunnable) that forwards no value and renders $0(), used by triggerAfter.
1b1041c to
6765fea
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Add
UI.triggerAfter(Duration, SerializableRunnable), which runs a task on theserver once the given delay has elapsed. The delay is measured by the browser
via a one-shot client timer that makes a normal round trip when it elapses, so
a single deferred event can be handled without enabling push.
This change:
a Registration; removing it clears the client timer, so a task cancelled
before its delay elapses does not run;
clears it on removal;
that forwards no value and renders $0(), used by triggerAfter.