Skip to content

[DB] feat: add keyed collection subscriptions#1515

Draft
lalitkapoor wants to merge 1 commit intoTanStack:mainfrom
lalitkapoor:codex/subscribe-key-changes
Draft

[DB] feat: add keyed collection subscriptions#1515
lalitkapoor wants to merge 1 commit intoTanStack:mainfrom
lalitkapoor:codex/subscribe-key-changes

Conversation

@lalitkapoor
Copy link
Copy Markdown

🎯 Changes

Adds collection.subscribeKeyChanges(key, callback) as a fine-grained subscription primitive for future changes to a single collection key. This lets callers pair collection.get(key) with a keyed subscription without creating a live query for row-level rendering.

The implementation reuses CollectionSubscription lifecycle behavior, registers keyed subscribers before sync starts so synchronous sync writes are not missed, and emits only changes matching the subscribed key.

✅ Checklist

  • I have tested this code locally with pnpm test.

Tested with:

  • pnpm --filter @tanstack/db exec vitest --run tests/collection-subscribe-changes.test.ts tests/collection.test-d.ts --typecheck.enabled --typecheck.ignoreSourceErrors
  • pnpm --filter @tanstack/db build

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant