vue.jsvuejs2vue-composition-api

What is 'effect' on Vue computed properties


If I inspect a computed property in Vue 2.7, I can see that, besides the well-known .value property, there's also .effect. I wasn't able to find any information about it, except that it's deprecated in Vue 3. Does anybody know why it was needed and what its use was? Why has it become deprecated? I'd also appreciate, if somebody shares a link to the page where this property would be documented.

Demonstration that computed properties have the 'effect' value


Solution

  • It's an undocumented API for internal purposes that contains a watcher that updates the computed value:

    some libs rely on the presence effect for checking computed refs from normal refs, but the implementation doesn't matter

    This seems plausible, because in Vue 3 computed and other special kinds of refs have internal properties that make them different from regular refs, but they don't exist in Vue 2 reactivity API.

    In Vue itself, it's used for testing.