Skip to content

Add support for array mutating methods in proxy change tracking #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025

Conversation

KyleAMathews
Copy link
Collaborator

Summary

• Add proper tracking for array mutating methods (push, pop, shift, unshift, splice, sort, reverse, fill, copyWithin)
• Fix existing array tests that were misleadingly named but didn't actually call the methods they claimed to test
• Add comprehensive test coverage for all supported array mutating methods

Test plan

  • All existing proxy tests continue to pass
  • New array method tests verify proper change tracking
  • Original objects remain unchanged while proxy tracks mutations
  • All 62 proxy tests passing

🤖 Generated with Claude Code

Implement proper tracking for array methods like push(), pop(), shift(),
unshift(), splice(), sort(), reverse(), fill(), and copyWithin().
Previously, these methods were not intercepted by the proxy, causing
changes to go untracked.

- Add array method detection in proxy get trap
- Update existing array tests to actually call the methods they claim to test
- Add comprehensive tests for all supported array mutating methods

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

changeset-bot bot commented Jul 15, 2025

🦋 Changeset detected

Latest commit: ddb37fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@tanstack/db Patch
@tanstack/electric-db-collection Patch
@tanstack/query-db-collection Patch
@tanstack/react-db Patch
@tanstack/vue-db Patch
@tanstack/db-example-react-todo Patch

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

Copy link

pkg-pr-new bot commented Jul 15, 2025

@tanstack/db-example-react-todo

@tanstack/db

npm i https://pkg.pr.new/@tanstack/db@267

@tanstack/electric-db-collection

npm i https://pkg.pr.new/@tanstack/electric-db-collection@267

@tanstack/query-db-collection

npm i https://pkg.pr.new/@tanstack/query-db-collection@267

@tanstack/react-db

npm i https://pkg.pr.new/@tanstack/react-db@267

@tanstack/vue-db

npm i https://pkg.pr.new/@tanstack/vue-db@267

commit: ddb37fa

Copy link
Contributor

Size Change: +36 B (+0.1%)

Total Size: 34.8 kB

Filename Size Change
./packages/db/dist/esm/proxy.js 3.79 kB +36 B (+0.96%)
ℹ️ View Unchanged
Filename Size
./packages/db/dist/esm/collection.js 8.45 kB
./packages/db/dist/esm/deferred.js 230 B
./packages/db/dist/esm/errors.js 150 B
./packages/db/dist/esm/index.js 568 B
./packages/db/dist/esm/local-only.js 815 B
./packages/db/dist/esm/local-storage.js 2.07 kB
./packages/db/dist/esm/optimistic-action.js 294 B
./packages/db/dist/esm/query/builder/functions.js 531 B
./packages/db/dist/esm/query/builder/index.js 3.49 kB
./packages/db/dist/esm/query/builder/ref-proxy.js 842 B
./packages/db/dist/esm/query/compiler/evaluators.js 1.34 kB
./packages/db/dist/esm/query/compiler/group-by.js 2.09 kB
./packages/db/dist/esm/query/compiler/index.js 1.48 kB
./packages/db/dist/esm/query/compiler/joins.js 1.15 kB
./packages/db/dist/esm/query/compiler/order-by.js 933 B
./packages/db/dist/esm/query/compiler/select.js 657 B
./packages/db/dist/esm/query/ir.js 318 B
./packages/db/dist/esm/query/live-query-collection.js 2.06 kB
./packages/db/dist/esm/SortedMap.js 1.24 kB
./packages/db/dist/esm/transactions.js 2.29 kB

compressed-size-action::db-package-size

Copy link
Contributor

Size Change: 0 B

Total Size: 1.05 kB

ℹ️ View Unchanged
Filename Size
./packages/react-db/dist/esm/index.js 152 B
./packages/react-db/dist/esm/useLiveQuery.js 902 B

compressed-size-action::react-db-package-size

Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@KyleAMathews KyleAMathews merged commit 665efe6 into main Jul 16, 2025
5 checks passed
@KyleAMathews KyleAMathews deleted the fix-array-proxy branch July 16, 2025 13:01
@github-actions github-actions bot mentioned this pull request Jul 16, 2025
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.

2 participants