Our component is designed to monitor signals from a Service:
export class PaginationComponent {
private readonly pageSize = this.listService.pageSize.asReadonly();
private readonly totalCount = this.listService.totalCount.asReadonly();
readonly pageCount = computed(() => Math.ceil(this.totalCount() / this.pageSize() || 1);
readonly pages = signal<number[]>([]);
constructor(
private readonly paginationService: PaginationService,
) { }
private calculatePages(): void {
this.pages.set([]);
}
}
The calculatePages
method in the code above populates this.pages
with the relevant information for pagination.
Is there a way to trigger this method automatically whenever this.pageCount
changes?