Skip to content
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

feat(angular-table): Improve proxy signal implementation for v9 - Maybe also v8 #5816

Merged
merged 21 commits into from
Nov 25, 2024

Conversation

riccardoperra
Copy link
Contributor

@riccardoperra riccardoperra commented Nov 24, 2024

This starts from #5817

Improving proxy implementation and reactive properties

@KevinVandy I've had some time to investigate about the current proxy implementation and some change detection issues we have sometimes in our applications related to how we pass the table instance in sub components and how's FlexRender works.

Currently it's working in most of cases, but depending on how you compose the table, sometimes you lose the ability to use reactive values:

  • If you just get values from the returned table object from createAngularTable, you're fine.
  • If you want to have reactive values for rows, cells, headers etc, you need to implement somehow a mechanism to to notify all child components in order to sync the UI. This may get harder as it seems if you compose the table with directives and components to extend it's behavior.
  • While using FlexRenderDirective with components (which usually get the props from the getContext fn), it happens that those are not updated in the UI (e.g. Angular: Issue with FlexRenderComponent not updating row references in context (injectFlexRenderContext) #5767)
  • (row|cell|header).getContext result table and createAngularTable are different objects. The first one is the plain table (non-reactive), the second one a reactive proxy or a signal.

In the current branch I've experimented with the table custom features, and I saw we could use it to make all objects reactive. Since I saw that also the v8 supports custom features, I suppose that could be done on that version too.

https://github.com/riccardoperra/table/blob/tanstack_v9_angular/packages/angular-table/src/reactivity.ts

Basically it's the same as the current proxy implementation, so we wrap the concerned properties into a computed. For testing purposes i've added a enableExperimentalReactivity property while creating the table that enable this new behavior.

The only thing that doesn't convince me about this is the heaviness. Depending on the size of the table, creating a reactive prop for every get* may bet slow, since it will be done also for every row/cell/header etc. With debugTable log perf it currently doesn't seem that heavy, but surely we could find a way to detect (also manually) which properties should be considered reactive

Note

This should not be a noticeable breaking change, but if we want to port this on v8 we could make it optional so that we don't risk to break anything. We'll wait for feedback, and then in v9 we could make it the default. Anyway the related issue (#5767) can be fixed without that, but the resolution is less performant performant and I'm not 100% sure it solves the problem (the fix is here)

Copy link

nx-cloud bot commented Nov 24, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 10e1fce. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx affected --targets=test:format,test:eslint,test:sherif,test:knip,test:lib,test:types,test:build,build --parallel=3
✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Nov 24, 2024

Open in Stackblitz

More templates

@tanstack/angular-table

npm i https://pkg.pr.new/@tanstack/angular-table@5816

@tanstack/lit-table

npm i https://pkg.pr.new/@tanstack/lit-table@5816

@tanstack/qwik-table

npm i https://pkg.pr.new/@tanstack/qwik-table@5816

@tanstack/react-table

npm i https://pkg.pr.new/@tanstack/react-table@5816

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/@tanstack/match-sorter-utils@5816

@tanstack/react-table-devtools

npm i https://pkg.pr.new/@tanstack/react-table-devtools@5816

@tanstack/solid-table

npm i https://pkg.pr.new/@tanstack/solid-table@5816

@tanstack/svelte-table

npm i https://pkg.pr.new/@tanstack/svelte-table@5816

@tanstack/table-core

npm i https://pkg.pr.new/@tanstack/table-core@5816

@tanstack/vue-table

npm i https://pkg.pr.new/@tanstack/vue-table@5816

commit: 10e1fce

@riccardoperra riccardoperra force-pushed the tanstack_v9_angular branch 2 times, most recently from e8e18d9 to 6cebaa7 Compare November 24, 2024 14:26
@riccardoperra riccardoperra changed the title feat(angular-table): Support tanstack v9, improve proxy signal implementation, support angular19 feat(angular-table): Improve proxy signal implementation for v9 Nov 24, 2024
@riccardoperra riccardoperra changed the title feat(angular-table): Improve proxy signal implementation for v9 feat(angular-table): Improve proxy signal implementation for v9 - Maybe also v8 Nov 24, 2024
@KevinVandy KevinVandy marked this pull request as ready for review November 25, 2024 17:08
@KevinVandy KevinVandy merged commit 9e8029f into TanStack:alpha Nov 25, 2024
4 of 5 checks passed
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