Skip to content

Commit 4710380

Browse files
ci: Version Packages (#208)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 4e053ab commit 4710380

File tree

14 files changed

+290
-99
lines changed

14 files changed

+290
-99
lines changed

.changeset/collection-lifecycle-management.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

.changeset/gold-friends-pull.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/solid-pandas-draw.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

examples/react/todo/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# examples/react/todo
22

3+
## 0.0.18
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`945868e`](https://github.com/TanStack/db/commit/945868e95944543ccf5d778409548679a952e249), [`57b5f5d`](https://github.com/TanStack/db/commit/57b5f5de6297326a57ef205a400428af0697b48b)]:
8+
- @tanstack/react-db@0.0.13
9+
- @tanstack/db-collections@0.0.16
10+
311
## 0.0.17
412

513
### Patch Changes

examples/react/todo/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "@tanstack/db-example-react-todo",
33
"private": true,
4-
"version": "0.0.17",
4+
"version": "0.0.18",
55
"dependencies": {
6-
"@tanstack/db-collections": "^0.0.15",
6+
"@tanstack/db-collections": "^0.0.16",
77
"@tanstack/query-core": "^5.75.7",
8-
"@tanstack/react-db": "^0.0.12",
8+
"@tanstack/react-db": "^0.0.13",
99
"cors": "^2.8.5",
1010
"drizzle-orm": "^0.40.1",
1111
"drizzle-zod": "^0.7.0",

packages/db-collections/CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# @tanstack/db-collections
22

3+
## 0.0.16
4+
5+
### Patch Changes
6+
7+
- feat: implement Collection Lifecycle Management ([#198](https://github.com/TanStack/db/pull/198))
8+
9+
Adds automatic lifecycle management for collections to optimize resource usage.
10+
11+
**New Features:**
12+
13+
- Added `startSync` option (defaults to `false`, set to `true` to start syncing immediately)
14+
- Automatic garbage collection after `gcTime` (default 5 minutes) of inactivity
15+
- Collection status tracking: "idle" | "loading" | "ready" | "error" | "cleaned-up"
16+
- Manual `preload()` and `cleanup()` methods for lifecycle control
17+
18+
**Usage:**
19+
20+
```typescript
21+
const collection = createCollection({
22+
startSync: false, // Enable lazy loading
23+
gcTime: 300000, // Cleanup timeout (default: 5 minutes)
24+
})
25+
26+
console.log(collection.status) // Current state
27+
await collection.preload() // Ensure ready
28+
await collection.cleanup() // Manual cleanup
29+
```
30+
31+
- Updated dependencies [[`945868e`](https://github.com/TanStack/db/commit/945868e95944543ccf5d778409548679a952e249), [`0f8a008`](https://github.com/TanStack/db/commit/0f8a008be8b368f231c8518ad1adfcac08132da2), [`57b5f5d`](https://github.com/TanStack/db/commit/57b5f5de6297326a57ef205a400428af0697b48b)]:
32+
- @tanstack/db@0.0.13
33+
334
## 0.0.15
435

536
### Patch Changes

packages/db-collections/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tanstack/db-collections",
33
"description": "A collection for (aspirationally) every way of loading your data",
4-
"version": "0.0.15",
4+
"version": "0.0.16",
55
"dependencies": {
66
"@tanstack/db": "workspace:*",
77
"@tanstack/query-core": "^5.75.7",

packages/db/CHANGELOG.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,85 @@
11
# @tanstack/db
22

3+
## 0.0.13
4+
5+
### Patch Changes
6+
7+
- feat: implement Collection Lifecycle Management ([#198](https://github.com/TanStack/db/pull/198))
8+
9+
Adds automatic lifecycle management for collections to optimize resource usage.
10+
11+
**New Features:**
12+
13+
- Added `startSync` option (defaults to `false`, set to `true` to start syncing immediately)
14+
- Automatic garbage collection after `gcTime` (default 5 minutes) of inactivity
15+
- Collection status tracking: "idle" | "loading" | "ready" | "error" | "cleaned-up"
16+
- Manual `preload()` and `cleanup()` methods for lifecycle control
17+
18+
**Usage:**
19+
20+
```typescript
21+
const collection = createCollection({
22+
startSync: false, // Enable lazy loading
23+
gcTime: 300000, // Cleanup timeout (default: 5 minutes)
24+
})
25+
26+
console.log(collection.status) // Current state
27+
await collection.preload() // Ensure ready
28+
await collection.cleanup() // Manual cleanup
29+
```
30+
31+
- Refactored the way we compute change events over the synced state and the optimistic changes. This fixes a couple of issues where the change events were not being emitted correctly. ([#206](https://github.com/TanStack/db/pull/206))
32+
33+
- Add createOptimisticAction helper that replaces useOptimisticMutation ([#210](https://github.com/TanStack/db/pull/210))
34+
35+
An example of converting a `useOptimisticMutation` hook to `createOptimisticAction`. Now all optimistic & server mutation logic are consolidated.
36+
37+
```diff
38+
-import { useOptimisticMutation } from '@tanstack/react-db'
39+
+import { createOptimisticAction } from '@tanstack/react-db'
40+
+
41+
+// Create the `addTodo` action, passing in your `mutationFn` and `onMutate`.
42+
+const addTodo = createOptimisticAction<string>({
43+
+ onMutate: (text) => {
44+
+ // Instantly applies the local optimistic state.
45+
+ todoCollection.insert({
46+
+ id: uuid(),
47+
+ text,
48+
+ completed: false
49+
+ })
50+
+ },
51+
+ mutationFn: async (text) => {
52+
+ // Persist the todo to your backend
53+
+ const response = await fetch('/api/todos', {
54+
+ method: 'POST',
55+
+ body: JSON.stringify({ text, completed: false }),
56+
+ })
57+
+ return response.json()
58+
+ }
59+
+})
60+
61+
const Todo = () => {
62+
- // Create the `addTodo` mutator, passing in your `mutationFn`.
63+
- const addTodo = useOptimisticMutation({ mutationFn })
64+
-
65+
const handleClick = () => {
66+
- // Triggers the mutationFn
67+
- addTodo.mutate(() =>
68+
- // Instantly applies the local optimistic state.
69+
- todoCollection.insert({
70+
- id: uuid(),
71+
- text: '🔥 Make app faster',
72+
- completed: false
73+
- })
74+
- )
75+
+ // Triggers the onMutate and then the mutationFn
76+
+ addTodo('🔥 Make app faster')
77+
}
78+
79+
return <Button onClick={ handleClick } />
80+
}
81+
```
82+
383
## 0.0.12
484

585
### Patch Changes

packages/db/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tanstack/db",
33
"description": "A reactive client store for building super fast apps on sync",
4-
"version": "0.0.12",
4+
"version": "0.0.13",
55
"dependencies": {
66
"@electric-sql/d2mini": "^0.1.2",
77
"@standard-schema/spec": "^1.0.0",

packages/react-db/CHANGELOG.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,86 @@
11
# @tanstack/react-db
22

3+
## 0.0.13
4+
5+
### Patch Changes
6+
7+
- feat: implement Collection Lifecycle Management ([#198](https://github.com/TanStack/db/pull/198))
8+
9+
Adds automatic lifecycle management for collections to optimize resource usage.
10+
11+
**New Features:**
12+
13+
- Added `startSync` option (defaults to `false`, set to `true` to start syncing immediately)
14+
- Automatic garbage collection after `gcTime` (default 5 minutes) of inactivity
15+
- Collection status tracking: "idle" | "loading" | "ready" | "error" | "cleaned-up"
16+
- Manual `preload()` and `cleanup()` methods for lifecycle control
17+
18+
**Usage:**
19+
20+
```typescript
21+
const collection = createCollection({
22+
startSync: false, // Enable lazy loading
23+
gcTime: 300000, // Cleanup timeout (default: 5 minutes)
24+
})
25+
26+
console.log(collection.status) // Current state
27+
await collection.preload() // Ensure ready
28+
await collection.cleanup() // Manual cleanup
29+
```
30+
31+
- Add createOptimisticAction helper that replaces useOptimisticMutation ([#210](https://github.com/TanStack/db/pull/210))
32+
33+
An example of converting a `useOptimisticMutation` hook to `createOptimisticAction`. Now all optimistic & server mutation logic are consolidated.
34+
35+
```diff
36+
-import { useOptimisticMutation } from '@tanstack/react-db'
37+
+import { createOptimisticAction } from '@tanstack/react-db'
38+
+
39+
+// Create the `addTodo` action, passing in your `mutationFn` and `onMutate`.
40+
+const addTodo = createOptimisticAction<string>({
41+
+ onMutate: (text) => {
42+
+ // Instantly applies the local optimistic state.
43+
+ todoCollection.insert({
44+
+ id: uuid(),
45+
+ text,
46+
+ completed: false
47+
+ })
48+
+ },
49+
+ mutationFn: async (text) => {
50+
+ // Persist the todo to your backend
51+
+ const response = await fetch('/api/todos', {
52+
+ method: 'POST',
53+
+ body: JSON.stringify({ text, completed: false }),
54+
+ })
55+
+ return response.json()
56+
+ }
57+
+})
58+
59+
const Todo = () => {
60+
- // Create the `addTodo` mutator, passing in your `mutationFn`.
61+
- const addTodo = useOptimisticMutation({ mutationFn })
62+
-
63+
const handleClick = () => {
64+
- // Triggers the mutationFn
65+
- addTodo.mutate(() =>
66+
- // Instantly applies the local optimistic state.
67+
- todoCollection.insert({
68+
- id: uuid(),
69+
- text: '🔥 Make app faster',
70+
- completed: false
71+
- })
72+
- )
73+
+ // Triggers the onMutate and then the mutationFn
74+
+ addTodo('🔥 Make app faster')
75+
}
76+
77+
return <Button onClick={ handleClick } />
78+
}
79+
```
80+
81+
- Updated dependencies [[`945868e`](https://github.com/TanStack/db/commit/945868e95944543ccf5d778409548679a952e249), [`0f8a008`](https://github.com/TanStack/db/commit/0f8a008be8b368f231c8518ad1adfcac08132da2), [`57b5f5d`](https://github.com/TanStack/db/commit/57b5f5de6297326a57ef205a400428af0697b48b)]:
82+
- @tanstack/db@0.0.13
83+
384
## 0.0.12
485

586
### Patch Changes

0 commit comments

Comments
 (0)