Conversation
🦋 Changeset detectedLatest commit: 04fb63a The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: +656 B (+1.09%) Total Size: 60.8 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 1.05 kB ℹ️ View Unchanged
|
KyleAMathews
left a comment
There was a problem hiding this comment.
Is resetting to loading to also reset the query pipeline?
balegas
left a comment
There was a problem hiding this comment.
The code looks good, but I have a couple of observations that might make or not make sense with the collection.
- The shape is not invalid at the point of must-refetch, could you mask the loading state by keeping the state of the shape while you refetch it?
- Why do you need a new
loadingstate instead of resetting to the initial state of the shape, e.g. marking it not ready?
Good question, I don't think it will. We need a way to handle that in the live query. I think, but need to check, that the live query will not update until it goes back to ready.
Yes, we could. The intention here was that the live query would see the loading state and not commit its changes - essentially masking it at the live query level. I think there is a wider question here of is we want to go back into "loading" when this happen, but also if there are other reasons any other sync engine wants to go back into loading. One thought I had was for partitioned collections, when requesting a partition that requires to be sure a new query is "read" we likely need to go back into loading. But again that maybe want to be more fine grained, so only triggering loading for live queries that span a loading partition. My thinking here is that we are going from, everything breaks at the moment, to a first stop towards making this work. we can refine it. |
|
Another way of doing this could be to delete every key and then reinsert everything? |
|
Yep, I'm now rethinking this, we should "schedule a truncate" and then do that at the bending of the next commit. It's the pattern we used in pglite. We can go back and think about loading state later on - we need to, but no rush now. |
|
Yeah, maybe even just a begin()
truncate()
insert()
insert()
insert()
commit() |
|
Now has a transactional |
085f976 to
894f350
Compare
894f350 to
7634818
Compare
this also introduces a
truncate()method that a sync provider can use. There are through tests to ensure that the optimistic state is maintained after a truncate and resync.