valtiojs / valtio-yjs

valtio-yjs makes yjs state easy
MIT License
270 stars 15 forks source link

Refactor to minimize the number of redundant iterations #40

Closed tarabishy2020 closed 6 months ago

tarabishy2020 commented 1 year ago

I was going through the code and noticed that SubscribeP function and parseProxyOps are a bit confusing as there are redundant iterations going on there.

parseProxyOps works on the whole set of operations, but those could be related to different paths, yet it's still being called multiple times for each operation.

The refactor makes sure parseProxyOps is called one time. And arrayOps are processed on a per path basis.

codesandbox-ci[bot] commented 1 year ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3d45aec7c7add017c59c703739465f5dba8fabeb:

Sandbox Source
React Configuration
React Typescript Configuration
dai-shi commented 6 months ago

I like the idea to improve the performance, bug https://github.com/valtiojs/valtio-yjs/pull/40#discussion_r1294170803 is not acceptable.