Implementation of the reactivity connections to propagate changes between objects.
Basic usage:
import { ref, computed, toRaw } from '@distributedlab/reactivity'
const newPerson = () => {
const age = ref(30)
const name = computed(() => 'John')
const changeAge = (newAge: number) => {
age.value = newAge
}
return toRaw({ age, name, changeAge })
}
const john = newPerson()
console.log(john.age) // 30
console.log(john.name) // John
obj.changeAge(35)
console.log(john.age) // 35
Usage with extending:
const newHuman = () => {
const age = ref(25)
const changeAge = (newAge: number) => {
age.value = newAge
}
return toRaw({ age, changeAge })
}
const newPerson = () => {
const parent = newHuman()
const name = computed(() => 'John')
return toRaw(extend(parent, { name }))
}
const person = newPerson()
console.log(person.age) // 25
person.changeAge(30)
console.log(person.age) // 30
For the change log, see CHANGELOG.md.
Generated using TypeDoc