Skip to content

feat: add UI.triggerAfter for deferred server-side callbacks#24538

Open
Artur- wants to merge 1 commit into
mainfrom
feature/run-after
Open

feat: add UI.triggerAfter for deferred server-side callbacks#24538
Artur- wants to merge 1 commit into
mainfrom
feature/run-after

Conversation

@Artur-

@Artur- Artur- commented Jun 7, 2026

Copy link
Copy Markdown
Member

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.

@github-actions github-actions Bot added the +0.0.1 label Jun 7, 2026
@Artur- Artur- requested a review from Legioth June 7, 2026 08:55
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Test Results

 1 442 files  +3   1 442 suites  +3   1h 24m 10s ⏱️ + 1m 55s
10 123 tests +6  10 055 ✅ +6  68 💤 ±0  0 ❌ ±0 
10 595 runs  +6  10 526 ✅ +6  69 💤 ±0  0 ❌ ±0 

Results for commit 6765fea. ± Comparison against base commit 979e73a.

♻️ This comment has been updated with latest results.

@Artur- Artur- marked this pull request as ready for review June 8, 2026 06:31
@Artur-

Artur- commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Use case this this feature would be at least:

  1. Temporarily changing a text in the UI and then changing it back, e.g. Changing a "Copy" button to "Copied" and then 1s later back to "Copy":
button.setText("Copied"); UI.getCurrentOrThrow().runAfter(Duration.ofSeconds(1), () -> button.setText("Copy")})
  1. Delaying initialization of a view or part of a view
// 0 still forces a client round trip
UI.getCurrentOrThrow().runAfter(Duration.ofSeconds(0), () -> { doHeavyInit();})

@Legioth Legioth removed their request for review June 8, 2026 07:13
@Legioth

Legioth commented Jun 8, 2026

Copy link
Copy Markdown
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.

@mshabarov mshabarov self-requested a review June 8, 2026 11:35
@Artur- Artur- changed the title feat: add UI.runAfter for deferred server-side callbacks feat: add UI.triggerAfter for deferred server-side callbacks Jun 8, 2026
@github-actions github-actions Bot added +0.1.0 and removed +0.0.1 labels Jun 8, 2026
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.
@Artur- Artur- force-pushed the feature/run-after branch from 1b1041c to 6765fea Compare June 10, 2026 07:26
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🔎Iteration reviews

Development

Successfully merging this pull request may close these issues.

3 participants