oldValue support
This commit is contained in:
parent
6784e18198
commit
656bb21ca2
|
@ -4,20 +4,14 @@ export function observe(target) {
|
|||
target.observe = true
|
||||
}
|
||||
|
||||
let preValue = null
|
||||
let prePath = null
|
||||
let preEle = null
|
||||
|
||||
export function proxyUpdate(ele) {
|
||||
let timeout = null
|
||||
ele.data = new JSONProxy(ele.data).observe(false, info => {
|
||||
if (preValue === info.value && prePath === info.path && preEle === ele) {
|
||||
if (info.oldValue === info.value) {
|
||||
return
|
||||
}
|
||||
|
||||
preValue = info.value
|
||||
prePath = info.path
|
||||
preEle = ele
|
||||
clearTimeout(timeout)
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
|
|
|
@ -57,7 +57,7 @@ const JSONPatcherProxy = (function() {
|
|||
function setTrap(instance, target, key, newValue) {
|
||||
const parentPath = findObjectPath(instance, target)
|
||||
|
||||
const destinationPropKey = parentPath + '/' + escapePathComponent(key)
|
||||
const destinationPropKey = parentPath + '/' + escapePathComponent(key)
|
||||
|
||||
if (instance.proxifiedObjectsMap.has(newValue)) {
|
||||
const newValueOriginalObject = instance.proxifiedObjectsMap.get(newValue)
|
||||
|
@ -145,7 +145,8 @@ const JSONPatcherProxy = (function() {
|
|||
}
|
||||
}
|
||||
operation.value = newValue
|
||||
}
|
||||
}
|
||||
operation.oldValue = target[key]
|
||||
const reflectionResult = Reflect.set(target, key, newValue)
|
||||
instance.defaultCallback(operation)
|
||||
return reflectionResult
|
||||
|
|
Loading…
Reference in New Issue