Clarify what is an "async callback" in "Stopping a Watcher"
Nobody has claimed this yet.
- Dominant language
- Vue
- Stars
- 3.2k
- Forks
- 5k
- Avg merge
- 14d 17h
- Merged PRs (30d)
- 1
Description
I'm referring to section Stopping a Watcher on the Composable page.
It says:
The key here is that the watcher must be created synchronously: if the watcher is created in an async callback, it won't be bound to the owner component and must be stopped manually to avoid memory leaks.
There's then an example where watch is incorrectly called inside a setTimeout callback.
The terms "synchronously" and "async callback" are confusing with respect to top-level await inside a script setup component.
In the current Vue release, it is safe to call watch after await, as the SFC compiler keeps track of current component instance across await boundaries.
This fact is actually called out on page Composables, section Usage restrictions.
Also important: is the watcher still cleaned-up if the component is removed before even being mounted (i.e. before await resolves)?
This SFC Playground shows that this situation is safe as the watcher does not even run.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Composables page's Usage restrictions section and compare the wording around synchronous watcher creation with the linked SFC Playground example. Verify the behavior after top-level await and when the component is removed before mounting. Done means the documentation clearly defines “async callback” and explains the cleanup behavior without contradicting the current Vue release.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100