-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: visual-diff wait for async elements #17
Conversation
src/browser/fixture.js
Outdated
|
||
const update = elem?.updateComplete; | ||
if (typeof update === 'object' && Promise.resolve(update) === update) { | ||
await update; | ||
await nextFrame(); | ||
} | ||
|
||
if (opts.awaitLoadingComplete && typeof elem?.getLoadingComplete === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the potential use cases for not wanting to wait for getLoadingComplete
, if it exists? To vdiff skeletons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was the only use case I could think of, which is why I defaulted this to ON.
render() { | ||
return html`<slot></slot>`; | ||
} | ||
async getLoadingComplete() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda outside the scope of this PR, but worth bring up because I believe James might be starting on the skeleton group loading stuff soon - do you envision this being the same piece that could be used for the grouped skeletons, to tell the parent "I'm done loading and awaiting confirmation to turn off my skeleton". Or by all HM components in general, to indicate they're done?
Or do you see this as mostly a test/vdiff thing, and those will use cases will look more like the async container stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question, these things are definitely related.
The mechanism as it's used here is more of a 1-time thing that the tests wait for, whereas theoretically the skeleton stuff could go from loading -> ready and then back to loading, in which case the skeleton container and all the items in it should likely go back into skeleton mode.
For that reason my mind went more to the subscriber stuff for the skeletons. This also doesn't need to be set in stone -- once we figure out what works for the skeleton collection we can try this out with it and also try out visual-diff in some hypermedia repos and then adjust as necessary.
Co-authored-by: Danny Gleckler <[email protected]>
Co-authored-by: Danny Gleckler <[email protected]>
Co-authored-by: Danny Gleckler <[email protected]>
🎉 This PR is included in version 0.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Small improvement to the
fixture
method which allows components to define an optionalgetLoadingComplete()
method (similar togetUpdateComplete()
) andfixture
will wait for it to resolve before proceeding.