diff --git a/index.js b/index.js index 9141146..d2c905f 100644 --- a/index.js +++ b/index.js @@ -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'