Can reconcile be used on its own?
Hi! The documentation doesn't go into a lot of detail on what reconcile does exactly. Can I use it "on its own" detached from reactivity? That is, is it just a function that shallowly diffs and unions the two objects? Or does it 'communicate' with reactivity somehow?
The context here is that I'm trying to pre-optimize a custom signal-returning function that I already know will change frequently and have a lot of rows singly nested in an array, with only a few rows being added to the bottom each time. I currently have it working as a signal, not a store, but I'd like to try using reconcile here anyway. I realize the answer here might be "no, just use a store," but that's exactly what I'm asking essentially and I'm also just curious.
4 Replies
reconcile
is implemented specifically to solid stores
you probably need to find other library for reconciling any js object
but doing that will probably cause some issues down the line
like you have a signal with a list of messages:
Got it, thank you for your help! I really just switched to signals for my use case because it was a somewhat complex query result with loading state and I wanted different reactivity at various levels. At the same time, I am learning Solid for the first time and stores are kinda hard to grapple with at first, signals are much more straightforward. So, this was really just an attempt to avoid stores.
Next time I revisit this logic, I'll just switch back to stores, and try to isolate the trouble I was having further
what stores and do you can do on your own too
maybe I answered the question about reconcile a bit too literally
this is how you would do the example with messages with just signals:
that's essentially how I'm doing it now, yes, returning 'results' and 'queryState' signals together as a tuple. The only weird bit is that I do manual diffing of old and new results in the update function (to maintain object references for unchanged rows) - but that is all localized to that function and not really anything to do with reactivity, I'm realizing