Computed refactor
What problem does this feature solve?
Computed property gets too hard too intuitviely identify what reactives it depends on when there is too much login in
What does the proposed API look like?
create a second arugent to identify its dependencies just like react does, e.g computed(()=>, [denpendencies])
Just FYI for anyone else interested in this functionality, there is a composable in VueUse that does the same thing - computedWithControl.
Example from the docs:
import { computedWithControl } from '@vueuse/core'
const source = ref('foo')
const counter = ref(0)
const computedRef = computedWithControl(
() => source.value, // watch source, same as `watch`
() => counter.value, // computed getter, same as `computed`
)
Vue's computed properties will always work this way - tracking reactive dependencies automatically. Vue's reactivity at its heart is precisely about automatic dependency tracking. And as there are existing solutions in the ecosystem to solve this edge case, I can say that we don't see a need to make this a part of Vue core.