diff --git a/src/models/page.ts b/src/models/page.ts index 550fc328..8487bd31 100644 --- a/src/models/page.ts +++ b/src/models/page.ts @@ -2,11 +2,12 @@ import {HttpClient} from "@angular/common/http"; export class Page { - this: string - next: string - first: string - count: number - items: T[] + this: string; + next: string; + first: string; + count: number; + items: T[]; + private _isLoading: boolean = false; constructor(init?:Partial>) { @@ -15,17 +16,20 @@ export class Page loadNext(client: HttpClient) { - if (this.next == null) + if (this.next == null || this._isLoading) return; + this._isLoading = true; client.get>(this.next).subscribe(x => { this.items.push(...x.items); this.count += x.count; this.next = x.next; this.this = x.this; + this._isLoading = false; }); } + changeType(type: string) { return this.first.replace(/\/\w*($|\?)/, `/${type}$1`)