Conversation
🦋 Changeset detectedLatest commit: 3805fcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: +241 B (+0.27%) Total Size: 89.7 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.35 kB ℹ️ View Unchanged
|
kevin-dp
left a comment
There was a problem hiding this comment.
Nice addition. I left just one nit.
|
|
||
| const subscription = new CollectionSubscription(this.collection, callback, { | ||
| ...options, | ||
| includeInitialState: options.includeInitialState, |
There was a problem hiding this comment.
I'd rather keep ...options because spreading is more future proof in case we add new fields to the options. But i understand we want to spread all except where. Perhaps:
const { where, ...opts } = options
const subscription = new CollectionSubscription(this.collection, callback, {
...opts,
whereExpression,
...There was a problem hiding this comment.
@claude please apply the fix described in my previous comment.
There was a problem hiding this comment.
Claude finished @kevin-dp's task in 1m 1s —— View job
Applied Kevin's suggested fix
Todo List
- Read current implementation in
packages/db/src/collection/changes.ts - Apply destructuring fix to make spreading more future-proof
- Commit and push changes
Summary
I've applied the fix to use destructuring for more future-proof option spreading in packages/db/src/collection/changes.ts:113-128.
The change:
- Destructures
wherefromoptionsand spreads the rest asopts - Spreads
...optswhen creating theCollectionSubscriptioninstead of manually listing properties - This ensures any future options will automatically be passed through without code changes
The commit has been pushed to the PR branch.
--- | Branch: claude/whereexpression-subscribechanges-01CAXj3xYLmTeA1ZGtxzz6Hv
Add a `where` callback option to `SubscribeChangesOptions` that allows
filtering changes using query builder functions (eq, gt, and, etc.)
with a row proxy, instead of requiring manual IR construction with
PropRef.
Before:
```ts
import { eq, PropRef } from "@tanstack/db"
collection.subscribeChanges(callback, {
whereExpression: eq(new PropRef(["status"]), "active")
})
```
After:
```ts
import { eq } from "@tanstack/db"
collection.subscribeChanges(callback, {
where: (row) => eq(row.status, "active")
})
```
Changes:
- Add generic `where` callback to `SubscribeChangesOptions<T>`
- Compile `where` callback to `whereExpression` in CollectionChangesManager
- Update JSDoc examples to show correct usage
- Add tests for single and multiple condition filtering
459b741 to
9225ffd
Compare
|
I rebased this branch and CI is green. I'll have Claude fix my nit and then it should be ready to go. |
Co-authored-by: Kevin <kevin-dp@users.noreply.github.com>
|
🎉 This PR has been released! Thank you for your contribution! |
Add a
wherecallback option toSubscribeChangesOptionsthat allows filtering changes using query builder functions (eq, gt, and, etc.) with a row proxy, instead of requiring manual IR construction with PropRef.Before:
After:
Changes:
wherecallback toSubscribeChangesOptions<T>wherecallback towhereExpressionin CollectionChangesManager🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact