theKashey / proxyequal

There is a bit more smart way to compare things, than a shallow equal.
MIT License
72 stars 7 forks source link

When proxyShallow should be used? #21

Open user753 opened 5 years ago

user753 commented 5 years ago

If I understand correctly it's just a slightly better version of shallowEqual but with the cost of proxy usage. With consideration of the proxy cost can I assume that it always works faster than shallowEqual? Why would I want to use proxyShalloow instead of proxyEqual?

theKashey commented 5 years ago

This is not only "when" question, but also "why". You might find some answers in my article How I wrote the world’s fastest memoization library, and in the series of articles and "usage-tracking" packages @dai-shi have created.

In short - proxyEqual is not shallowEqual. Even if they have similar signatures and doing almost the same job - they are different. proxyEqual requires one more argument, which contains all keys you are going to compare, and that list is generated by a factual usage, ie usage tracking.

But anyway there are 3 function to use - proxyEqual, proxyShallow, proxyShallowEqual, and dont forget about proxyState. And what is the difference.

And proxyState is providing the right memoization orchestration to make it even faster.

And look like it's time to update documentation :)

user753 commented 5 years ago

And look like it's time to update documentation :)

It would be great. d.ts file doesn't even have proxyShallowEqual. Also, there is a typo in package.json "types": "proxyqual.d.ts",