By webfansplz @webfansplz
For this challenge, you'll use Reactivity API: effectScope
to complete the challenge.
Here's what you need to implement 👇:
<script setup lang="ts">
import { ref, computed, watch, watchEffect } from "vue"
const counter = ref(1)
const doubled = computed(() => counter.value * 2)
// use the `effectScope` API to make these effects stop together after being triggered once
watch(doubled, () => console.log(doubled.value))
watchEffect(() => console.log("Count: ", doubled.value))
counter.value = 2
setTimeout(() => {
counter.value = 4
})
</script>
<template>
<div>
<p>
{{ doubled }}
</p>
</div>
</template>