Skip to content

Switch to Collection options factories instead of extending the Collection class - #145

Merged
KyleAMathews merged 5 commits into
mainfrom
options
Jun 9, 2025
Merged

KyleAMathews merged 5 commits into
mainfrom
options

Conversation

@KyleAMathews

Copy link
Copy Markdown
Collaborator

This refactors ElectricCollection and QueryCollection into factory functions (electricCollectionOptions and queryCollectionOptions) that return standard CollectionConfig objects and utility functions. Also adds a createCollection function to standardize collection instantiation.

Partially fixes #132

…ction class

This refactors ElectricCollection and QueryCollection into factory functions
(electricCollectionOptions and queryCollectionOptions) that return standard
CollectionConfig objects and utility functions. Also adds a createCollection
function to standardize collection instantiation.
@changeset-bot

changeset-bot Bot commented Jun 6, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8ac8101

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tanstack/db-collections Patch
@tanstack/db-example-react-todo Patch
@tanstack/db Patch
@tanstack/react-db Patch
@tanstack/vue-db Patch

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

@KyleAMathews
KyleAMathews requested a review from samwillis June 6, 2025 17:47
@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2025 •

Copy link
Copy Markdown

@tanstack/db-example-react-todo

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

commit: 8ac8101

@samwillis samwillis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines +216 to 218
if (!config.sync) {
throw new Error(`Collection requires a sync config`)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not really related to this PR, but in the thoughts about a "local collection", could we just make sync optional? then to create a local collection it's just a call to createCollection()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

hmm yeah possibly! We'd still have to handle "sync" internally to immediately take commited transactions and write it to the store. Perhaps this is a good base case though.

@KyleAMathews
KyleAMathews merged commit e4feb0c into main Jun 9, 2025
@KyleAMathews
KyleAMathews deleted the options branch June 9, 2025 12:18
@github-actions github-actions Bot mentioned this pull request Jun 9, 2025
cursor Bot pushed a commit that referenced this pull request Jul 16, 2025
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.

Refactor core collection API

2 participants