parent
95bcfc5a17
commit
76778071c9
@ -1,15 +1,9 @@
|
|||||||
const state = new Proxy(
|
const watch = (value, callback)=>{
|
||||||
{
|
return new Proxy(value, { set: callback })
|
||||||
fun:true
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
set: (target, prop, value) => {
|
|
||||||
console.log(`Property ${prop} changed from ${target[prop]} to ${value}`);
|
|
||||||
target[prop] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log(state);
|
const state = watch({ name: 'matt' }, (newValue) => {
|
||||||
state.fun = false
|
console.log(newValue);
|
||||||
console.log(state);
|
})
|
||||||
|
|
||||||
|
state.name = 'Matthew'
|
||||||
|
|||||||
Loading…
Reference in new issue