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(watchArray): new function #1705
Conversation
This function is handy when using hooks with v-for: <div v-for="k in num" :ref="refs.set">{{ k }}</div> const refs = useTemplateRefsList<HTMLDivElement>()
watchListChanges(refs, (_new, _old, added) => {
for (let el of added) {
useEventListener(el, 'click', () => console.log('clicked!'))
}
}, { deep: true }) |
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
@antfu Thanks for your feedback, I've renamed this function to |
console.log(added) // [4] | ||
console.log(removed) // [] |
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.
Can added
and removed
also have meta data like [{ value: 4, index: 3 }]
?
Description
This PR adds a new watcher helper
watchListChanges
. This function monitors the changes made to a list and notifies the callback with the added and removed elements.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).