Skip to content

use useSyncExternalStore for useLiveQuery #225

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

Merged
merged 2 commits into from
Jul 6, 2025

Conversation

samwillis
Copy link
Collaborator

No description provided.

@samwillis samwillis requested a review from KyleAMathews July 3, 2025 08:10
Copy link

changeset-bot bot commented Jul 3, 2025

⚠️ No Changeset found

Latest commit: 8075f8a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Jul 3, 2025

@tanstack/db-example-react-todo

npm i https://pkg.pr.new/@tanstack/db@225
npm i https://pkg.pr.new/@tanstack/db-collections@225
npm i https://pkg.pr.new/@tanstack/react-db@225
npm i https://pkg.pr.new/@tanstack/vue-db@225

commit: 8075f8a

Copy link
Contributor

github-actions bot commented Jul 3, 2025

Size Change: +42 B (+0.14%)

Total Size: 30 kB

Filename Size Change
./packages/db/dist/esm/query/live-query-collection.js 2.02 kB +42 B (+2.13%)
ℹ️ View Unchanged
Filename Size
./packages/db/dist/esm/collection.js 7.86 kB
./packages/db/dist/esm/deferred.js 230 B
./packages/db/dist/esm/errors.js 150 B
./packages/db/dist/esm/index.js 570 B
./packages/db/dist/esm/optimistic-action.js 294 B
./packages/db/dist/esm/proxy.js 3.75 kB
./packages/db/dist/esm/query/builder/functions.js 525 B
./packages/db/dist/esm/query/builder/index.js 3.27 kB
./packages/db/dist/esm/query/builder/ref-proxy.js 851 B
./packages/db/dist/esm/query/compiler/evaluators.js 1.34 kB
./packages/db/dist/esm/query/compiler/group-by.js 2.09 kB
./packages/db/dist/esm/query/compiler/index.js 1.42 kB
./packages/db/dist/esm/query/compiler/joins.js 1.16 kB
./packages/db/dist/esm/query/compiler/order-by.js 933 B
./packages/db/dist/esm/query/compiler/select.js 657 B
./packages/db/dist/esm/query/ir.js 310 B
./packages/db/dist/esm/SortedMap.js 1.24 kB
./packages/db/dist/esm/transactions.js 1.33 kB

compressed-size-action::db-package-size

@samwillis samwillis force-pushed the samwillis/useSncExtStore branch from 2fb3fa9 to 5e53026 Compare July 3, 2025 08:12
Copy link
Contributor

github-actions bot commented Jul 3, 2025

Size Change: 0 B

Total Size: 661 B

ℹ️ View Unchanged
Filename Size
./packages/react-db/dist/esm/index.js 152 B
./packages/react-db/dist/esm/useLiveQuery.js 509 B

compressed-size-action::react-db-package-size

Copy link
Collaborator

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! :shipit:

const snapshotRef = useRef<{
state: Map<any, any>
data: Array<any>
collection: Collection<any, any, any>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we still infer the collection types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are inferred in the function overloads, this is just internal and the type declaration was redundant.

@samwillis samwillis merged commit 1b73361 into query2 Jul 6, 2025
4 checks passed
@samwillis samwillis deleted the samwillis/useSncExtStore branch July 6, 2025 15:33
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

Successfully merging this pull request may close these issues.

2 participants