JSONPatcherProxy icon indicating copy to clipboard operation
JSONPatcherProxy copied to clipboard

Add "oldValue" to a patch

Open dntzhang opened this issue 7 years ago • 1 comments

https://github.com/Tencent/omi

Hope to support oldValue:

{op: "replace", path: "/a/b", value: "aaa2", oldValue: "aaa1"}

If it is convenient, you can review this for omi. I added only one line of code. https://github.com/Tencent/omi/blob/master/packages/omi/src/proxy.js#L149

dntzhang avatar Nov 06 '18 23:11 dntzhang

Thanks @dntzhang for the kind words. I took the liberty to rename the title to reflect the content of your comment.

oldValue is not part of the JSON Patch standard, but maybe we could either:

  1. implement this as a non-enumerable property
  2. or, add it as a second argument to the observed callback

warpech avatar Mar 25 '19 11:03 warpech