Add old value as third parameter to listener callbacks

This commit is contained in:
Talia 2021-10-19 18:08:22 +02:00
parent fd58f3b437
commit b28dd09709
No known key found for this signature in database
GPG key ID: AD727AD22802D0D6

View file

@ -24,8 +24,8 @@ export default (target={}) => {
let proxy = new Proxy(target, { let proxy = new Proxy(target, {
set: (target, prop, value) => { set: (target, prop, value) => {
console.log(callbacks) console.log(callbacks)
if (callbacks.has("*")) callbacks.get("*").forEach(callback => callback(value, prop)) if (callbacks.has("*")) callbacks.get("*").forEach(callback => callback(value, prop, target[prop]))
if (callbacks.has(prop)) callbacks.get(prop).forEach(callback => callback(value, prop)) if (callbacks.has(prop)) callbacks.get(prop).forEach(callback => callback(value, prop, target[prop]))
return Reflect.set(target, prop, value) return Reflect.set(target, prop, value)
}, },
get: (target, prop, value) => { get: (target, prop, value) => {