import { RdLib } from '../../base/rdLib'; import { RdComponent } from '../../base/rdComponent'; export interface IProviderContent { params: any; response: any; proxy: any; items: Array; state: { serviceCalled: boolean; waitingForResponse: boolean; responseIsRecieved: boolean; serviceCallFailed: boolean; }; paging: { currentPage: number; pageSize: any totalItemCount: number; totalPageCount: number; }; } export abstract class ServiceProviderPagingBase extends RdComponent { content: IProviderContent = { params: null, response: null, proxy: null, items: [], state: { serviceCalled: false, waitingForResponse: false, responseIsRecieved: false, serviceCallFailed: false }, paging: { currentPage: 1, pageSize: null, totalItemCount: null, totalPageCount: null } }; protected callState(params, proxy) { this.content.params = RdLib.objectOperations.deepCopy(params); this.content.proxy = proxy; this.content.response = null; this.content.state = { serviceCalled: true, waitingForResponse: true, responseIsRecieved: false, serviceCallFailed: false }; } protected successState(response) { this.content.response = response; this.content.state = { serviceCalled: true, waitingForResponse: false, responseIsRecieved: true, serviceCallFailed: false }; } protected errorState() { this.content.response = null; this.content.items = []; this.content.state = { serviceCalled: true, waitingForResponse: false, responseIsRecieved: true, serviceCallFailed: true }; this.content.paging = { currentPage: 1, pageSize: null, totalItemCount: null, totalPageCount: null } this.error("service call failed"); } abstract call(params); abstract gotoPage(pageNumber); abstract refresh(); abstract getAllItems(progressCallback?: (currentIteration: number, totalIterationCount: number) => void): Promise; }