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.
To bring the functionality more inline with Vue's implementation of
$nextTick
, the magic returns a Promise that resolves when the callback is run.This allows pausing your own functions until after pending DOM updates without needing to handle your own scheduling.
Shouldn't break anything since nobody should be assigning the output of
$nextTick
to anything anyway.Side Story:
I was having issues with the reactivity related to an array between two components where the last update to the array would not be reflected in the DOM (and one or two other similar things) and I dove into the Vue reactivity docs and they mentioned using
$nextTick
when there are rendering issues, and I tried it and it worked for Alpine, even without the await 🤷, but I was curious about the implementation and potential benefits of enabling a very Alpiney options for waiting for DOM updates.