Skip to content
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

Add Promise to $nextTick #2841

Merged
merged 1 commit into from Apr 19, 2022
Merged

Add Promise to $nextTick #2841

merged 1 commit into from Apr 19, 2022

Conversation

ekwoka
Copy link
Contributor

@ekwoka ekwoka commented Apr 15, 2022

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.

@calebporzio
Copy link
Collaborator

I like this, Thanks!

@calebporzio calebporzio merged commit 2ef9314 into alpinejs:main Apr 19, 2022
@ekwoka ekwoka deleted the $nextTick-adjustment branch August 9, 2022 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants