-
Notifications
You must be signed in to change notification settings - Fork 104
Add Pre-created Collection Support to useLiveInfiniteQuery #684
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
Conversation
🦋 Changeset detectedLatest commit: 34f8801 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Size Change: +56 B (+0.07%) Total Size: 83.7 kB
ℹ️ View Unchanged
|
Size Change: 0 B Total Size: 2.36 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
🎉 This PR has been released! Thank you for your contribution! |
Summary
Extends
useLiveInfiniteQuery
to accept pre-createdLiveQueryCollection
instances in addition to query functions, enabling router loader patterns where collections can be created, awaited for preload, and then passed to route components.Changes
Core Functionality
useLiveInfiniteQuery
now accepts either:(q) => q.from(...).orderBy(...).limit(...)
createLiveQueryCollection({ query: ... })
New API:
getWindow()
on LiveQueryCollectionUtilsgetWindow()
method to inspect current window settings{ offset: number, limit: number } | undefined
undefined
for non-windowed queriesCollectionConfigBuilder
Validation & Error Handling
orderBy
clause (throws error if missing)CollectionImpl
or functionType Safety
instanceof CollectionImpl
for reliable runtime type checkingExample Usage
Router Loader Pattern
Traditional Query Function (unchanged)
Testing
Implementation Notes
useEffect
afteruseLiveQuery
subscribes to avoid triggering subscription callbacks during render which React will log warnings abouthasValidatedCollectionRef
to track first-time validation and only log warnings onceuseLiveQuery
hook