-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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): angular adapter implementation with signals #5442
feat(angular-table): angular adapter implementation with signals #5442
Conversation
* update demo
af717cf
to
8885e95
Compare
8885e95
to
8516ea7
Compare
@riccardoperra Wondering how much of your proxy can be replicated with TanStack Angular Store: https://tanstack.com/store/latest/docs/framework/angular/quick-start. I originally thought we'd have to wait until TanStack Table v9 to introduce state subscriptions, but this looks interesting. |
Not sure about that. Hope I understood, but In this case I think the - const table = signal(createTable(resolvedOptionsSignal()), {
- equal: () => false,
- })
+ const table = new Store(createTable(resolvedOptionsSignal())) then in the effect we should update the store instead of the signal - table.update(v => v)
+ table.setState(...) Then for each property that should be treated as a "slice", we should replace the computed with the injectStore value = injectStore(table, (state) => state[property](), { injector }) However, I think this implicate that for each property a new writeable signal and an effect will be created, wouldn't it be less performant / consuming more memory than a computed fn? |
I'd like to get one of these approaches in the main PR ASAP so that we can march forward on the rest of it with signals. Thoughts @crutchcorn when you have time? |
Not sure having an approach where the table is componentized is recommended, (does the other frameworks do this aswell?. @Component({
selector: 'my-user-table',
template: `
@if (table(); as table) {
...
}
`,
standalone: true,
})
class MyUserTableComponent {
table = input.required<TableResult>();
}
@Component({
template: `
<my-user-table [table]="table()/>
`
})
class AppComponent {
table = createAngularTable(() => ({
data: this.data
});
constructor() {
this.http.get('...').subscribe(() => this.data.set(data))
}
} Is it better to create the table instance inside the table component and, for example, just pass the data as input? Anyway, I had to update the |
bcfe467
to
129f921
Compare
@riccardoperra I'm not really sure what that means. But if it means passing the table instance around to components as a param/prop, that's common. https://github.com/KevinVandy/material-react-table/blob/v2/packages/material-react-table/src/components/table/MRT_Table.tsx |
Once a direction has been chosen, let's mark this as ready to review and merge to the main PR |
this is weird. I don't remember merging this, but it's merged into my PR. @riccardoperra can we move forward with one of the signal adapters you proposed this week and keep working on it? |
This is still a wip implementation of the angular adapter with a mixed approach:
The adapter will always return a
signal
table. This is useful if passed as a component input. That signal change on every state/option change. If a signal has been used within the options, the table object will be updated automatically.I've also added in this pr the
proxy
implementation, where the signal it's extended with a proxified object that allows state slicing. This may not be useful for the adapter, I'm not sure about this and and it would be nice to have some feedback, but maybe "it's too much work" and it's a pain to mantain.Also, we need to check if there are some caveats with that approach. Internally I'm using
computed
which memoize the value by default, so in case the view will marked as dirty only if the value instance change (Object.is). This could be a premature optimization considering that almost every property would be transformed.The first one (signal-only) is safer, and even with it you can do "state slicing", you just need to manually use computed.
I've updated demo code but I may opt to make them simpler as was done for the others. Also, the unit/integration test part is missing. Note also that this implementation doesn't cover required inputs signals (need to wrap with lazy-signal-initializer / lazy-init as described here)