Closed theKashey closed 2 years ago
I reckon sooner or later proxies will make their way to the "read" part, as immer made it's way to the "write" part. But it does not to be today. Let's wait for a solution we all can recommend without a second thought.
Based on:
Proxy based solutions were floating around for a while, and actually actively used inside(MobX) and outside of React ecosystem(especially in Vue and Immer). I am opening this discussion to resolve status quo and add some momentum to Redux + Proxies investigations.
Overall proxies are capable to solve 3 objective:
proxy-memoize
orredux-tracked
// reading only
.a
and.b
const fn = memoize(x => ({ sum: x.a + x.b, diff: x.a - x.b }));fn({ a: 2, b: 1, c: 1 }); // ---> { sum: 3, diff: 1 } fn({ a: 3, b: 1, c: 1 }); // ---> { sum: 4, diff: 2 } fn({ a: 3, b: 1, c: 9 }); // ---> { sum: 4, diff: 2 } (returning old value) // ^ "c" does not matter