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 implementation and cleanup code #5518
feat(angular-table): improve implementation and cleanup code #5518
Conversation
Fix typo. Deleted the duplicate word 'based'
* docs: faceting docs and filter example reorg * update lock file
☁️ Nx Cloud ReportCI is running/has finished running commands for commit f651c6c. 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 ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
These changes got merged into the main |
@merto20 this is not the expected usage in my opinion. With this approach you'll call You should call data = signal<Person[]>([])
table = createAngularTable(() => ({
data: this.data()
})) |
@riccardoperra |
This adapter follow the same rules as the other ones, and it works the way angular signals expect to be
Angular Query does the same, since it follows the readonly query = injectQuery(() => ({
queryKey: [this.data()] // this is a signal
}) If you want to use it outside, and in your case if you want to use a computed to store the table, which I think is wrong (you're recreating from scratch the table instance), you can do something like that. Using computed table = computed(() =>
runInInjectionContext(this.injector, () =>
createAngularTable(() => ({
data: this.data(),
columns: defaultColumns,
getCoreRowModel: getCoreRowModel(),
debugTable: true,
}))
)
) Using ngOnInit/other hooksexport class AppComponent implements OnInit {
readonly injector = inject(Injector);
data = signal<Person[]>(defaultData)
table?: Table<Person>
ngOnInit() {
runInInjectionContext(this.injector, () => {
this.table = createAngularTable(() => ({
data: this.data(),
columns: defaultColumns,
getCoreRowModel: getCoreRowModel(),
debugTable: true,
}));
})
}
} Note that this is the same behavior you encounter if you do something like toObservable/toSignal/effect inside a computed. Those are functions that you can use only inside an Surely before publishing the adapter we should write the documentation and highlight that |
@riccardoperra what I meant was you can optionally add |
With this pr i'm fixing the failing build for #5432. I'm also adding the remaining examples and ultimating the proxy implementation which it has been simplified and seems to work for all cases.
There are a lot of changes since I updated the branch with
origin/main