Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Why isn't a reactive variable watchable?

I am developing a simple application in Vue3 and TypeScript. I defined an interface and initialized a reactive variable scrap that I the wanted to watch:

interface Scrap {
  Text: string,
  ModificationDate: string,
}
const scrap = ref<Scrap>({ Text: '', ModificationDate: '' } as Scrap)
watch(() => scrap, () => console.log('change'))

scrap.Text is modified in the application UI and I see these changes in DevTools → Vue.

The watch() callback is however not fired, despite that change. What is the reason for that?

I tried both watch(scrap, () => console.log('change')) and watch(() => scrap, () => console.log('change')) but there were no difference in behaviour (nor errors or warnings).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In case the whole object is watched, it should be a deep watcher:

watch(scrap, () => console.log('change'), { deep: true })

Otherwise a specific property should be watched:

watch(() => scrap.value.Text, () => console.log('change'))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!