-
Notifications
You must be signed in to change notification settings - Fork 114
Implement collection lifecycle PRD proposals #198
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
samwillis
merged 17 commits into
main
from
cursor/implement-prd-proposals-and-run-tests-9ff9
Jun 26, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
564f211
Implement collection lifecycle management with sync and GC support
cursoragent aa0aaeb
Changes from background composer bc-9b3085f3-fa87-4223-90c8-1624dc9f315e
cursoragent 36952cb
fix linting
samwillis 884ab18
fix formmatting in changeset
samwillis 964a494
add optional startSync config
samwillis 2133e11
Merge main into collection lifecycle implementation
samwillis 06e817c
add back tests
samwillis 96dc472
fix changeset
samwillis d7cdf3d
return unsub fn from electric sync
samwillis c18f1cd
fixed things from review
samwillis 7f3a3d6
fix hooks
samwillis 8647c6b
update changeset
samwillis 93b879f
Merge branch 'main' into cursor/implement-prd-proposals-and-run-tests…
samwillis 6d18036
validate state transistions
samwillis 97e582e
Add catch and rethrow of sync cleanup error, plus tests
samwillis d7ce1a7
throw if activeSubscribersCount < 0
samwillis 2708e73
wrap user signal
samwillis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| "@tanstack/db": patch | ||
| "@tanstack/vue-db": patch | ||
| "@tanstack/react-db": patch | ||
| "@tanstack/db-collections": patch | ||
| --- | ||
|
|
||
| feat: implement Collection Lifecycle Management | ||
|
|
||
| Adds automatic lifecycle management for collections to optimize resource usage. | ||
|
|
||
| **New Features:** | ||
|
|
||
| - Added `startSync` option (defaults to `false`, set to `true` to start syncing immediately) | ||
| - Automatic garbage collection after `gcTime` (default 5 minutes) of inactivity | ||
| - Collection status tracking: "idle" | "loading" | "ready" | "error" | "cleaned-up" | ||
| - Manual `preload()` and `cleanup()` methods for lifecycle control | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```typescript | ||
| const collection = createCollection({ | ||
| startSync: false, // Enable lazy loading | ||
| gcTime: 300000, // Cleanup timeout (default: 5 minutes) | ||
| }) | ||
|
|
||
| console.log(collection.status) // Current state | ||
| await collection.preload() // Ensure ready | ||
| await collection.cleanup() // Manual cleanup | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.