This is really easy to fix inside of Cashay, simply invalidate the denormalized response after the user's mutationHandler mutates it & then leave it to the query method to reconstruct it. Or even faster, send back a clone of the mutated response.
However, I think that's what I did in a previous version, albeit I can't remember if it was just a premature performance boost, or if there was a legitimate reason for it.
To avoid a future regression, here's the why:
react-redux caches the result of of mSTP to avoid rerendering stuff, which is great.
When a mutationHandler mutates a cached result, it's going to be shallowly equal to the previous result, since it points to the same place in memory (those darn mutative actions).
Now react-redux does one better and actually checks the next level down. For example, instead of reading just cachedResult.response.data, it also checks to see if all of its children use the same pointers. So, by doing a shallowPlus1Clone, we successfully tell react-redux to rerender, while still being really really really ridiculously fast going.
See https://github.com/ParabolInc/action/issues/97, which involves this problem + needs to use mSTP to get the user.
This is really easy to fix inside of Cashay, simply invalidate the denormalized response after the user's
mutationHandler
mutates it & then leave it to thequery
method to reconstruct it. Or even faster, send back a clone of the mutated response.However, I think that's what I did in a previous version, albeit I can't remember if it was just a premature performance boost, or if there was a legitimate reason for it.
To avoid a future regression, here's the why:
react-redux
caches the result of ofmSTP
to avoid rerendering stuff, which is great. When amutationHandler
mutates a cached result, it's going to be shallowly equal to the previous result, since it points to the same place in memory (those darn mutative actions). Nowreact-redux
does one better and actually checks the next level down. For example, instead of reading justcachedResult.response.data
, it also checks to see if all of its children use the same pointers. So, by doing ashallowPlus1Clone
, we successfully tell react-redux to rerender, while still being really really really ridiculously fast going.