docs(examples): migrate content-full-layout-scroll example to use rxResource - #2365
docs(examples): migrate content-full-layout-scroll example to use rxResource#2365mistrykaran91 wants to merge 1 commit into
Conversation
4a8f90f to
8c39b0f
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors the component to use Angular signals and rxResource for data fetching and state management, removing manual change detection and subscriptions. The review feedback suggests removing the hardcoded page limit in favor of dynamic values from the page signal, making setPage private, and simplifying the isLoading signal by avoiding an unnecessary computed wrapper.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| [totalRowCount]="rows.length" | ||
| (currentPageChange)="table.onFooterPage({ page: $event })" | ||
| [currentPage]="page().pageNumber + 1" | ||
| [totalPages]="maxPageNumber" |
There was a problem hiding this comment.
Instead of using the hardcoded maxPageNumber (which is limited to 10), bind [totalPages] to the dynamic totalPages property from the page() signal. This ensures the pagination correctly reflects the actual number of pages available from the service.
| [totalPages]="maxPageNumber" | |
| [totalPages]="page().totalPages" |
| setPage(pageRequest: PageRequest): void { | ||
| const requestedPage = Math.min(pageRequest.offset, this.maxPageNumber - 1); | ||
| const current = this.pageRequest(); | ||
| if (current.offset !== requestedPage || current.pageSize !== pageRequest.pageSize) { | ||
| this.pageRequest.set({ ...pageRequest, offset: requestedPage }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Update setPage to dynamically limit the requested page using this.page().totalPages instead of the hardcoded maxPageNumber. Additionally, since setPage is only called internally by setPaginationPage, we can change its visibility to private.
private setPage(pageRequest: PageRequest): void {
const totalPages = this.page().totalPages;
const requestedPage = totalPages > 0 ? Math.min(pageRequest.offset, totalPages - 1) : pageRequest.offset;
const current = this.pageRequest();
if (current.offset !== requestedPage || current.pageSize !== pageRequest.pageSize) {
this.pageRequest.set({ ...pageRequest, offset: requestedPage });
}
}| [count]="page().totalElements" | ||
| [offset]="page().pageNumber" | ||
| [limit]="page().size" | ||
| [ghostLoadingIndicator]="isLoading() > 0" |
| protected readonly maxPageNumber = 10; | ||
| private readonly pageRequest = signal<PageRequest>({ offset: 0, pageSize: 10 }); |
There was a problem hiding this comment.
Remove the hardcoded maxPageNumber property since the total number of pages should be dynamically retrieved from the page() signal.
| protected readonly maxPageNumber = 10; | |
| private readonly pageRequest = signal<PageRequest>({ offset: 0, pageSize: 10 }); | |
| private readonly pageRequest = signal<PageRequest>({ offset: 0, pageSize: 10 }); |
| protected readonly rows = computed(() => | ||
| this.dataResource.isLoading() ? [] : (this.dataResource.value()?.data ?? []) | ||
| ); | ||
| protected readonly isLoading = computed(() => (this.dataResource.isLoading() ? 1 : 0)); |
There was a problem hiding this comment.
With the migration to rxResource, this.dataResource.isLoading is already a boolean signal. Avoid creating an intermediate computed signal just to read another signal's value, as the value from a signal is already memoized. We can assign the signal directly.
| protected readonly isLoading = computed(() => (this.dataResource.isLoading() ? 1 : 0)); | |
| protected readonly isLoading = this.dataResource.isLoading; |
References
- Avoid creating an intermediate
computedsignal just to read another signal's value. The value from a signal is already memoized, so an extracomputedsignal is redundant.
Documentation.
Examples.
Dashboards Demo.
Playwright report.
Coverage Reports: