Replies: 4 comments 3 replies
-
That final example can be implemented using a const myVar = ref(initialValue)
const myVarWrapper = computed({
get() {
return myVar.value
},
set(val) {
console.trace('myVar was changed to', val)
myVar.value = val
}
}) Docs: https://vuejs.org/guide/essentials/computed.html#writable-computed Using a |
Beta Was this translation helpful? Give feedback.
-
Do you need the following functionality? watch(
() => isActiveChartPaneAction.value,
newIsActiveChartPaneAction => {
console.log('IS_ACTIVE_PANE_CHART_ACTION', newIsActiveChartPaneAction)
},
{
onTrack(e) {
console.log(e) // DebuggerEvent
},
onTrigger(e) {
console.log(e) // DebuggerEvent
},
},
) According to the official documentation: This is also supported in |
Beta Was this translation helpful? Give feedback.
-
There's no stack trace or anything that's attached to your watcher. The function you pass as the first argument is run on every tick, and if the return value changes, the 2nd callback is executed. I doubt the internals even know since the watch source is executed in complete isolation from the code that triggered the change.
is about all you have access to. |
Beta Was this translation helpful? Give feedback.
-
// I think it's a good idea to have something that helps debug what triggers the watch. watch( // I could wrap every assignment to the value, but that would require changing the whole codebase where the value is being set, which is not ideal. // Adding a proxy-like wrapper to log changes to the ref, which helps debug the source of updates without modifying existing assignments. const myVar = ref(initialValue); const myVarWrapper = { // It's a simple idea, but it could improve the developer experience when debugging reactive variables. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I think it's a good idea to have something that helps debug what triggers the
watch
.In my case, I have a
ref
that changes very frequently, and it's hard to track what exactly caused the change.I could wrap every assignment to the value, but that would require changing the whole codebase where the value is being set, which is not ideal.
Maybe using a proxy-like wrapper could help, something like this:
It's a simple idea, but it could improve the developer experience when debugging reactive variables.
Beta Was this translation helpful? Give feedback.
All reactions