dai-shi/proxy-memoize

Tracking changes in nested objects/arrays doesn't work sometimes

Closed this issue · 5 comments

Hello. I really like this library and I consider using it in our project.
I've faced an issue with tracking changes in nested objects or arrays.

Please open src/index.ts in this sandbox:
https://codesandbox.io/p/sandbox/vigilant-mountain-m7ntcs

On the bottom you can find finalSelector is called with state1 and state2.
Everything is fine, the result is correct, and I see CALCULATE! appears twice in the console.

However, when I uncomment // const names = selectAllNames(state); line in the intermediateSelector something happens. I can see only one CALCUALTE! log in the console, which means that the result returned from the intermediateSelector is incorrect.

Could you clarify if that's a bug, or I'm doing something wrong? Thanks

Interesting. So, it's caused by a memoized selector whose value is unused.
We probably assume somewhere that values are used and returned.
Not sure how easy to fix it, but we think this is a bug...

I wonder if anyone wants to tackle this.

any updates? I'm not very familiar with the code, but if you can provide some clues on where to fix this, I can try work on it

I guess one would need to read the code carefully and get used to it. I know it's very hard and only a few developers have done it.

I'm looking into it.