How to do partial reconcile?
I'd like to use reconcile on a partial / subset of my data.
How do you do this?
My best idea so far is to write this for loop:
However this triggers a setState for each key, which isn't that good from a performance point of view, I guess.
reconcile seems to require the full state object to be present.
Has anyone written a reconcile which can take partial state as input?
Should I use batch()?
Or a simple reconcile with {...this.state, ...data}?
3 Replies
both works but batch + selective reconcile should be more optimal
reconcile could even provide this through a flag, may be make a case somewhere impactful
thank you
by could do you mean, it'd be a nice idea for future development, or it's already supported, I just need to find it?
And what's your opinion on produce()? Does that allow similar speedups like reconcile? By speedup, I mean that if the new data is the same as the old data on a sub-part of the tree, then it should not trigger an update.
Summarized all my points on a GitHub issue:
https://github.com/solidjs/solid/issues/2475
GitHub
reconcile: support "merge" in objects · Issue #2475 · solidjs/solid
A common pattern I believe is to reconcile partial state updates in stores. For example, part of a store is synced to a backend, so after a push-to-backend operation, it returns an up-to-date data ...