Skip to content

Instantly share code, notes, and snippets.

@ycmjason
Created February 26, 2020 16:26
Show Gist options
  • Save ycmjason/d9ba2c1448e02569231244855d27346c to your computer and use it in GitHub Desktop.
Save ycmjason/d9ba2c1448e02569231244855d27346c to your computer and use it in GitHub Desktop.
import { reactive, watch } from './reactivity';
const r1 = reactive({ x: 1 })
const r2 = reactive({ x: 100 })
setInterval(() => {
r1.x++
}, 1000)
setInterval(() => {
r2.x--
}, 5000)
watch(() => {
console.log(`r1.x: ${r1.x}`)
})
watch(() => {
console.log(`r2.x: ${r2.x}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment