Skip to content

feat: add window.Vaadin.Flow.ready() and whenReady(callback)#24240

Draft
Artur- wants to merge 3 commits intomainfrom
feature/when-ready
Draft

feat: add window.Vaadin.Flow.ready() and whenReady(callback)#24240
Artur- wants to merge 3 commits intomainfrom
feature/when-ready

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 1, 2026

Define ready() as the canonical Promise-based "wait until Flow is idle" API and whenReady(callback) as a thin callback adapter for TestBench-style usage. Both are inlined into the bootstrap HTML so they are available on every Flow page in dev and production mode.

ready() resolves once document.readyState is complete, window.Vaadin.Flow.devServerIsNotLoaded is falsy, at least one client with isActive() has been registered, and all such clients report inactive. The "at least one client" requirement avoids a false positive before Flow has bootstrapped. ready() takes an optional { timeout } (default 30s) and rejects on timeout instead of polling forever. whenReady(callback) invokes the callback either when ready() resolves or after logging the rejection on timeout, so the callback contract holds either way.

The dev-mode-not-ready page sets ready and whenReady to false as not-ready sentinels for TestBench.

Define ready() as the canonical Promise-based "wait until Flow is
idle" API and whenReady(callback) as a thin callback adapter for
TestBench-style usage. Both are inlined into the bootstrap HTML so
they are available on every Flow page in dev and production mode.

ready() resolves once document.readyState is complete,
window.Vaadin.Flow.devServerIsNotLoaded is falsy, at least one client
with isActive() has been registered, and all such clients report
inactive. The "at least one client" requirement avoids a false
positive before Flow has bootstrapped. ready() takes an optional
{ timeout } (default 30s) and rejects on timeout instead of polling
forever. whenReady(callback) invokes the callback either when ready()
resolves or after logging the rejection on timeout, so the callback
contract holds either way.

The dev-mode-not-ready page sets ready and whenReady to false as
not-ready sentinels for TestBench.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Test Results

 1 394 files  ±0   1 394 suites  ±0   1h 16m 30s ⏱️ + 1m 8s
10 068 tests ±0   9 998 ✅ ±0  70 💤 ±0  0 ❌ ±0 
10 543 runs  ±0  10 464 ✅ ±0  79 💤 ±0  0 ❌ ±0 

Results for commit a6f8ac3. ± Comparison against base commit f4c473a.

♻️ This comment has been updated with latest results.

Artur- added 2 commits May 1, 2026 22:09
The leading guard comment in whenReady.js was breaking the
startsWith assertion. Move the warning about disallowed // comments
onto the WHEN_READY_JS field's javadoc, where future maintainers of
the inlining are more likely to see it, and relax the test to use
contains so unrelated changes to whenReady.js do not break it.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 2, 2026

@Artur- Artur- marked this pull request as draft May 4, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant