@gonvex/react 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
React bindings for Gonvex.
|
|
4
4
|
|
|
5
5
|
This package provides the provider and hooks used by generated Gonvex bindings:
|
|
6
|
-
`useQuery`, `useMutation`, `useAction`,
|
|
7
|
-
compatibility exports.
|
|
6
|
+
`useQuery`, `useQueryResult`, `useMutation`, `useAction`, `useSync`,
|
|
7
|
+
`useSyncSelector`, auth-aware providers, and Convex-style compatibility exports.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -76,6 +76,30 @@ const { isWebSocketConnected, hasEverConnected, connectionRetries } = useConvexC
|
|
|
76
76
|
This reflects the real WebSocket lifecycle (not a stub). Mutations/actions
|
|
77
77
|
reject with `GonvexClientError` on timeout or disconnect and never hang forever.
|
|
78
78
|
|
|
79
|
+
## Durable sync collections
|
|
80
|
+
|
|
81
|
+
`useSync` reads a bounded entity collection from the client's normalized
|
|
82
|
+
IndexedDB store, then updates it as the server resumes or snapshots the durable
|
|
83
|
+
Postgres cursor:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
const tasks = useSync<Task>(api.tasks.recent, { workspaceId });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `useSyncSelector` when a component needs only derived state:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
const openCount = useSyncSelector<Task, number>(
|
|
93
|
+
api.tasks.recent,
|
|
94
|
+
{ workspaceId },
|
|
95
|
+
(tasks) => tasks.filter((task) => task.status === "open").length,
|
|
96
|
+
);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Both hooks return `undefined` before any local/server snapshot is available and
|
|
100
|
+
accept `"skip"` as the args value. Selectors use `Object.is` by default and
|
|
101
|
+
accept a custom equality function as the fourth argument.
|
|
102
|
+
|
|
79
103
|
## Native Google auth
|
|
80
104
|
|
|
81
105
|
Enable Google for the project and generate a configured auth module:
|
|
@@ -119,6 +143,8 @@ The package also exports Convex-style names for incremental migration:
|
|
|
119
143
|
- `useConvexConnectionState`
|
|
120
144
|
- `usePaginatedQuery`
|
|
121
145
|
- `useQueryResult`
|
|
146
|
+
- `useSync`
|
|
147
|
+
- `useSyncSelector`
|
|
122
148
|
|
|
123
149
|
## Related Packages
|
|
124
150
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gonvex/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@gonvex/client": "0.1.
|
|
17
|
-
"@gonvex/protocol": "0.1.
|
|
16
|
+
"@gonvex/client": "0.1.20",
|
|
17
|
+
"@gonvex/protocol": "0.1.20"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=19"
|