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