You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add warnOnce utility and improve deprecation warnings
- Add warnOnce utility to prevent console spam (logs each warning once)
- QueryCollection: warn about deprecated auto-refetch behavior
- QueryCollection: clarify { refetch: false } is correct pattern for now
- ElectricCollection: use warnOnce for { txid } return deprecation
- Update docs to accurately describe current vs v1.0 behavior
- Update changeset with clearer migration guidance
Co-Authored-By: Claude Opus 4.5 <[email protected]>
**Deprecation**: Mutation handler return values and QueryCollection auto-refetch behavior.
8
8
9
9
**What's changed:**
10
10
11
11
- Handler types now default to `Promise<void>` instead of `Promise<any>`, indicating the new expected pattern
12
-
- Old return patterns (`return { refetch }`, `return { txid }`) still work at runtime with deprecation warnings
13
-
-**Deprecation warnings** are now logged when handlers return values
14
-
- Old patterns will be fully removed in v1.0
12
+
-**Deprecation warnings** are now logged (once per session) when deprecated patterns are used
13
+
- Warnings now use `warnOnce` to avoid console spam
15
14
16
-
**New pattern (explicit sync coordination):**
15
+
**QueryCollection changes:**
17
16
18
-
-**Query Collections**: Call `await collection.utils.refetch()` to sync server state
19
-
-**Electric Collections**: Call `await collection.utils.awaitTxId(txid)` or `await collection.utils.awaitMatch(fn)` to wait for synchronization
20
-
-**Other Collections**: Use appropriate sync utilities for your collection type
17
+
-Auto-refetch after handlers is **deprecated** and will be removed in v1.0
18
+
-To skip auto-refetch now, return `{ refetch: false }` from your handler
19
+
-In v1.0: call `await collection.utils.refetch()` explicitly when needed, or omit to skip
21
20
22
-
This change makes the API more explicit and consistent across all collection types. All handlers should coordinate sync explicitly within the handler function using `await`, rather than relying on magic return values.
21
+
**ElectricCollection changes:**
23
22
24
-
Migration guide:
23
+
- Returning `{ txid }` is deprecated - use `await collection.utils.awaitTxId(txid)` instead
> **Note**: QueryCollection currently auto-refetches after handlers complete. See [Controlling Refetch Behavior](#controlling-refetch-behavior) for details on this transitional behavior.
235
+
238
236
### Controlling Refetch Behavior
239
237
240
-
After persisting mutations to your backend, call `collection.utils.refetch()` to sync the server state back to your collection. This ensures the local state matches the server state after server-side processing.
238
+
> **⚠️ Transitional API**: QueryCollection currently auto-refetches after handlers complete. This behavior is deprecated and will be removed in v1.0. See the migration notes below.
239
+
240
+
#### Current Behavior (Pre-1.0)
241
+
242
+
By default, QueryCollection automatically refetches after each handler completes. To **skip** auto-refetch, return `{ refetch: false }`:
0 commit comments