feat: add window.Vaadin.Flow.ready() and whenReady(callback)#24240
Draft
feat: add window.Vaadin.Flow.ready() and whenReady(callback)#24240
Conversation
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.
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.
|
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.



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.