Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace dirty checking with Proxy object #96

Closed
warpech opened this issue Apr 10, 2016 · 7 comments
Closed

Replace dirty checking with Proxy object #96

warpech opened this issue Apr 10, 2016 · 7 comments

Comments

@warpech
Copy link
Collaborator

warpech commented Apr 10, 2016

Proxy is a ES2016 feature that can replace dirty checking in https://github.com/Starcounter-Jack/JSON-Patch/blob/master/src/json-patch-duplex.ts

I think that the correct way is to replace the current dirty checking recursively with Proxy objects. The support in old browsers should be provided with a polyfill.

First step is to make a proof of concept implementation and check if the polyfill is capable of running it.

Read more:

@warpech
Copy link
Collaborator Author

warpech commented Apr 11, 2016

There might be a problem with proxy-polyfill. Readme says:

The polyfill supports just a limited subset of proxy 'traps', and comes with a caveat: it invokes seal on any proxied object so that no additional properties can be defined.

This means that we will not be able to add traps to properties added after the initial page load.

Maybe actually we can achieve what's needed by forking proxy-polyfill.

@warpech
Copy link
Collaborator Author

warpech commented Apr 11, 2016

Also, the performance cost of Proxy is quite significant: http://jsperf.com/es2015-proxy-test3. But I haven't yet compared it to the cost of dirty checking.

warpech referenced this issue Sep 9, 2016
Palindrom/Palindrom/issues/98

Partialy reverts Starcounter-Jack/JSON-Patch/commit/81ede07d94305bbdc53cf449717e7c3f4294cb46 (/issues/98)
@warpech
Copy link
Collaborator Author

warpech commented Dec 2, 2016

I know that some other frameworks attempted adapting Proxy and failed: vuejs/vue#3020. But perhaps our case is different.

@MarkHerhold
Copy link
Contributor

What is 'our case'?

@warpech
Copy link
Collaborator Author

warpech commented Dec 2, 2016

What is 'our case'?

Deep observing of a plain Javascript object without modifying it.

@alshakero
Copy link
Collaborator

Can I close this?

@warpech
Copy link
Collaborator Author

warpech commented Apr 26, 2017

Yes. Patch generation using ES6 Proxy was implemented as a separate package: https://github.com/Palindrom/JSONPatcherProxy

In this repo we continue to have dirty-checking based patch generation, but it will be deprecated in future. Follow #151

@warpech warpech closed this as completed Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants