Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deeply reactive query result #2

Open
thomasballinger opened this issue Apr 15, 2024 · 2 comments
Open

Deeply reactive query result #2

thomasballinger opened this issue Apr 15, 2024 · 2 comments

Comments

@thomasballinger
Copy link
Collaborator

The React client doesn't do this either yet, but it would nice to provide fine-grained reactivity by diffing query results to produce a series of modifications on a deeply reactive Svelte object.

@thomasballinger
Copy link
Collaborator Author

I looked into this a little, something like https://github.com/benjamine/jsondiffpatch could be used. This could look like

  • find undiffable types (maybe just ArrayBuffer?) and bail out to a full object update
  • diff the unreactive versions of these objects
  • apply that diff to the reactive object. jsondiffpatch provides one that might just work, or else reimplement the patcher.

We could use _id as the identity heuristic in arrays.

List views are the number one use case here, a first pass could operate only on query results that are arrays at the top level.

@thomasballinger
Copy link
Collaborator Author

TanStack query calls this "structural sharing," so it's sort of a normal thing to provide. Curious how svelte-query implements it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant