-
Notifications
You must be signed in to change notification settings - Fork 28
refactor: convert rows to signal input #520
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
Conversation
8a2caf2 to
f0ac168
Compare
f0ac168 to
f9dbe46
Compare
|
@fh1ch the sorting now behaves slightly differently. Before: // The same array will be sorted each time the users sorts.
// Assuming the are values, that have the same sort order.
// Then we have different results based on the order in which a user sorts columns
[...].sort().sort().sort()After // The original array is copied.
// We always get the same result.
// Independent of the order in which a user sorts.
const rows = [...];
rows.slice().sort();
rows.slice().sort();
rows.slice().sort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the rows input from a decorator-based input with getter/setter to an Angular signal input, and converts _internalRows from a plain array to a computed signal. This is part of a broader migration to Angular's signals-based reactivity system.
Key Changes
- Converted
rowsfrom@Input()decorator toinput<>()signal - Converted
_internalRowsfrom a mutable array to acomputed()signal that handles sorting, tree grouping, and ghost loading - Removed the
_rowsbacking field andtranslateColumns()method as they're no longer needed - Updated all references to
rowsand_internalRowsto call them as functions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| projects/ngx-datatable/src/lib/components/datatable.component.ts | Refactored rows to signal input, converted _internalRows to computed signal with internal logic for sorting and tree grouping, removed obsolete helper methods and effects |
| projects/ngx-datatable/src/lib/components/datatable.component.spec.ts | Updated test expectations to reflect changes in sort behavior (appears to be regression) |
| projects/ngx-datatable/src/lib/components/datatable.component.html | Updated template bindings to call _internalRows() as a function instead of accessing it as a property |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
projects/ngx-datatable/src/lib/components/datatable.component.ts
Outdated
Show resolved
Hide resolved
f9dbe46 to
07bac2f
Compare
fh1ch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spike-rabbit nice one, thanks a lot 🙇
LGTM 👍
As part of this change, `_internalRows` are now a computed signal. Further optimizations are done after rowGroups are turned into a signal as well.
07bac2f to
722eac7
Compare
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
rowsis a decorator input.What is the new behavior?
rowsis a signal input.Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications:
Other information:
Turns
_internalRowsinto a signal. There is more potential oncegroupedRowsis a signal as well.