projects/i-components/src/lib/services/data-provider.service.ts
The data provider service class
Properties |
|
Methods |
Accessors |
emitItemsCountDataAction | ||||||
emitItemsCountDataAction(data: any)
|
||||||
Emits the current status of items counting.
Parameters :
Returns :
void
|
emitRequestDataAction | ||||||
emitRequestDataAction(index: number)
|
||||||
Emit the selection action to trigger the load event every time the component is selected
Parameters :
Returns :
void
|
getPage |
getPage(skip: number, take: number)
|
API to retrieve the data from the component provider
Returns :
void
|
dataSource |
Type : any[]
|
DataSource array |
Private itemsCount |
Type : Subject<any>
|
Default value : new Subject<any>()
|
Subscriber to know comboboxItemCount. |
maxPageSize |
Type : number
|
Default value : 10
|
Max page size; |
pageResolver |
Type : function
|
Function that generates the collection that will be assigned to the virtual scrolled component |
Private requestData |
Type : Subject<any>
|
Default value : new Subject<any>()
|
Subscriber to request data action |
requestDataEvent |
getrequestDataEvent()
|
Subscribe to this to trigger the load event when the tab is selected.
Returns :
Observable<any>
|
itemsCountChanging |
getitemsCountChanging()
|
Gets the current status of items counting
Returns :
Observable<any>
|
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
/**
* The data provider service class
*
* @export
* @class DataProviderService
*/
@Injectable()
export class DataProviderService {
/**
* Subscriber to request data action
*
* @private
* @type {Subject<any>}
* @memberof DataProviderService
*/
private requestData: Subject<any> = new Subject<any>();
/**
* Max page size;
*
* @memberof DataProviderService
*/
maxPageSize = 10;
/**
* Subscriber to know comboboxItemCount.
*
* @private
* @type {Subject<any>}
* @memberof DataProviderService
*/
private itemsCount: Subject<any> = new Subject<any>();
/**
* DataSource array
*
* @type {any[]}
* @memberof DataProviderService
*/
dataSource: any[];
/**
* Function that generates the collection that will be assigned
* to the virtual scrolled component
*
* @memberof DataProviderService
*/
pageResolver: (items: any[], skip: number, take: number) => any;
/**
* API to retrieve the data from the component provider
*
* @param {number} skip
* @param {number} take
* @return {*}
* @memberof DataProviderService
*/
getPage(skip: number, take: number): void {
this.pageResolver(this.dataSource, skip, take);
}
/**
* Emit the selection action to trigger the
* load event every time the component is selected
*
* @param {number} index
* @memberof DataProviderService
*/
emitRequestDataAction(index: number): void {
this.requestData.next(index);
}
/**
* Emits the current status of items counting.
*
* @param {*} data
* @memberof DataProviderService
*/
emitItemsCountDataAction(data: any): void {
this.itemsCount.next(data);
}
/**
* Subscribe to this to trigger the load event when
* the tab is selected.
*
* @readonly
* @type {Observable<any>}
* @memberof TabItemService
*/
get requestDataEvent(): Observable<any> {
return this.requestData.asObservable();
}
/**
* Gets the current status of items counting
*
* @readonly
* @type {Observable<any>}
* @memberof DataProviderService
*/
get itemsCountChanging(): Observable<any> {
return this.itemsCount.asObservable();
}
}