const app = document.getElementById('app')
const data = {text: 'hello'}
const bucket = new Set()
const proxy = new Proxy(data, {
get(target, key){
bucket.add(effect);
return target[key];
},
set(target, key, val){
target[key] = val;
bucket.forEach(fn=>fn())
return true;
}
})
function effect(){
app.innerHTML = proxy.text;
}
effect()
proxy.text = 'world'
<div id="app"></div>