Skip to content

docs(examples): migrate content-full-layout-scroll example to use rxResource - #2365

Draft
mistrykaran91 wants to merge 1 commit into
mainfrom
docs/use-rx-resource-in-content-full-layout
Draft

docs(examples): migrate content-full-layout-scroll example to use rxResource#2365
mistrykaran91 wants to merge 1 commit into
mainfrom
docs/use-rx-resource-in-content-full-layout

Conversation

@mistrykaran91

@mistrykaran91 mistrykaran91 commented Jul 17, 2026

Copy link
Copy Markdown
Member

@mistrykaran91
mistrykaran91 force-pushed the docs/use-rx-resource-in-content-full-layout branch from 4a8f90f to 8c39b0f Compare July 17, 2026 06:36

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
[totalPages]="maxPageNumber"
[totalPages]="page().totalPages"

Comment on lines +108 to +114
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 });
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since isLoading() is now a boolean signal, we can bind it directly to [ghostLoadingIndicator] without the > 0 comparison.

Suggested change
[ghostLoadingIndicator]="isLoading() > 0"
[ghostLoadingIndicator]="isLoading()"

Comment on lines +78 to +79
protected readonly maxPageNumber = 10;
private readonly pageRequest = signal<PageRequest>({ offset: 0, pageSize: 10 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Remove the hardcoded maxPageNumber property since the total number of pages should be dynamically retrieved from the page() signal.

Suggested change
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
protected readonly isLoading = computed(() => (this.dataResource.isLoading() ? 1 : 0));
protected readonly isLoading = this.dataResource.isLoading;
References
  1. Avoid creating an intermediate computed signal just to read another signal's value. The value from a signal is already memoized, so an extra computed signal is redundant.

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.

1 participant