klis87 / normy

Automatic normalization and data updates for data fetching libraries (react-query, swr, rtk-query and more)
MIT License
257 stars 6 forks source link

Use structural sharing in addons if applicable #21

Open klis87 opened 8 months ago

klis87 commented 8 months ago

Currently we always normalize data after each query successful response. However, some libs like react-query uses structural sharing feature, which preserves data reference if it did not change. We could use this to normy advantage to give up normalization in such cases, as normalizating in this scenario will end up with the same normalized store.

This is especially useful for features like refetch on refocus, as then we can end up with multiple queries refetches at the same time, most of each will end up probably being the same.

klis87 commented 8 months ago

Done in https://github.com/klis87/normy/releases/tag/%40normy%2Fcore%400.10.0 .

I will keep it open though, as unfortunately for now it does not work with rtk-query. Awaiting https://github.com/reduxjs/redux-toolkit/issues/4073