Documentation improvement for computed property
Nobody has claimed this yet.
- Dominant language
- Vue
- Stars
- 3.2k
- Forks
- 5k
- Avg merge
- 14d 17h
- Merged PRs (30d)
- 1
Description
It would be helpful if in the computed documentation for vue 2 and 3 that:
In a computed property, if you try to access a property on the instance in a branch that doesn’t run, then Vue won’t know about that dependency and won’t re-run when that dependency is assigned a new value. Link to original quote
Example
When the IF test is TRUE, if the variables contained inside the ELSE statement and their values change, the computed is not triggered. E.g. computedInSomeCases
One way to prevent this, in case you want the computed to run always, is to use the variables outside the IF statement, like in computedAlways
computed: {
computedInSomeCases() {
return this.a ? this.b : this.c;
},
computedAlways() {
const b_copy = this.b;
const c_copy = this.c;
return this.a ? b_copy : c_copy;
},
},
data() {
return {
a: true,
b: 1,
c: 2
};
}
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 computed-property documentation for Vue 2 and Vue 3, using the quoted forum explanation and the provided example as the requirements. Review how conditional dependencies are currently described, then update the relevant documentation so the behavior and the shown workaround are clear; the work is done when both versions accurately explain the example.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100