Skip to content

Commit

Permalink
refactor(backend): all backend service methods renamed as processOnX
Browse files Browse the repository at this point in the history
- to remove confusion with Event Emitters, the 3 Backend Service API methods were renamed to start with the prefix "processOnX" instead of "onX"
- for example onFilterChanged is now processOnFilterChanged
  • Loading branch information
Ghislain Beaulac authored and Ghislain Beaulac committed May 23, 2018
1 parent 2cf1537 commit 9650568
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/examples/swt-common-grid-pagination.component.ts
Expand Up @@ -151,6 +151,6 @@ export class SwtCommonGridPaginationComponent implements OnInit {

onPageChanged(event?: Event, pageNumber?: number) {
this.logger.info('method [onPageChanged] - START/END', this.commonGrid);
this.commonGrid.onPaginationChanged(event, { newPage: pageNumber, pageSize: -1 });
this.commonGrid.processOnPaginationChanged(event, { newPage: pageNumber, pageSize: -1 });
}
}
6 changes: 3 additions & 3 deletions src/app/examples/swt-common-grid.component.ts
Expand Up @@ -332,7 +332,7 @@ export class SwtCommonGridComponent implements OnInit, AfterViewInit, BackendSer
* @param event
* @param args
*/
onFilterChanged( event: Event, args: FilterChangedArgs ): Promise<string> {
processOnFilterChanged( event: Event, args: FilterChangedArgs ): Promise<string> {
this.logger.info('method [onFilterChanged] - START', args);
this.filteredGridColumns = '';
let timing = 0;
Expand Down Expand Up @@ -369,7 +369,7 @@ export class SwtCommonGridComponent implements OnInit, AfterViewInit, BackendSer
* @param event
* @param args
*/
onPaginationChanged( event: Event, args: PaginationChangedArgs ) {
processOnPaginationChanged( event: Event, args: PaginationChangedArgs ) {
this.logger.info('method [onPaginationChanged] - START');
this.currentPage = args.newPage;
this.onPaginationChanged_.emit(args);
Expand All @@ -382,7 +382,7 @@ export class SwtCommonGridComponent implements OnInit, AfterViewInit, BackendSer
* @param event
* @param args
*/
onSortChanged( event: Event, args: SortChangedArgs ) {
processOnSortChanged( event: Event, args: SortChangedArgs ) {
this.logger.info('method [onSortChanged] - START');
this.sortedGridColumn = '';
const sortDirection = '|' + args.sortCols[0].sortAsc + '|';
Expand Down
Expand Up @@ -166,7 +166,7 @@ export class SlickPaginationComponent implements AfterViewInit, OnDestroy {
backendApi.preProcess();
}

const query = backendApi.service.onPaginationChanged(event, { newPage: pageNumber, pageSize: itemsPerPage });
const query = backendApi.service.processOnPaginationChanged(event, { newPage: pageNumber, pageSize: itemsPerPage });

// the process could be an Observable (like HttpClient) or a Promise
// in any case, we need to have a Promise so that we can await on it (if an Observable, convert it to Promise)
Expand Down
Expand Up @@ -55,11 +55,11 @@ export interface BackendService {
// -----------------

/** Execute when any of the filters changed */
onFilterChanged: (event: Event, args: FilterChangedArgs) => Promise<string>;
processOnFilterChanged: (event: Event, args: FilterChangedArgs) => Promise<string>;

/** Execute when the pagination changed */
onPaginationChanged: (event: Event | undefined, args: PaginationChangedArgs) => string;
processOnPaginationChanged: (event: Event | undefined, args: PaginationChangedArgs) => string;

/** Execute when any of the sorters changed */
onSortChanged: (event: Event, args: SortChangedArgs) => string;
processOnSortChanged: (event: Event, args: SortChangedArgs) => string;
}
Expand Up @@ -86,7 +86,7 @@ export class FilterService {
}

// call the service to get a query back
const query = await backendApi.service.onFilterChanged(event, args);
const query = await backendApi.service.processOnFilterChanged(event, args);

// emit an onFilterChanged event
this.emitFilterChanged('remote');
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/angular-slickgrid/services/graphql.service.ts
Expand Up @@ -244,7 +244,7 @@ export class GraphqlService implements BackendService {
/*
* FILTERING
*/
onFilterChanged(event: Event, args: FilterChangedArgs): Promise<string> {
processOnFilterChanged(event: Event, args: FilterChangedArgs): Promise<string> {
const gridOptions: GridOption = this._gridOptions || args.grid.getOptions();
const backendApi = gridOptions.backendServiceApi;

Expand Down Expand Up @@ -304,7 +304,7 @@ export class GraphqlService implements BackendService {
* }
* }
*/
onPaginationChanged(event: Event, args: PaginationChangedArgs) {
processOnPaginationChanged(event: Event, args: PaginationChangedArgs) {
const pageSize = +(args.pageSize || ((this.pagination) ? this.pagination.pageSize : DEFAULT_PAGE_SIZE));
this.updatePagination(args.newPage, pageSize);

Expand All @@ -317,7 +317,7 @@ export class GraphqlService implements BackendService {
* we will use sorting as per a Facebook suggestion on a Github issue (with some small changes)
* https://github.com/graphql/graphql-relay-js/issues/20#issuecomment-220494222
*/
onSortChanged(event: Event, args: SortChangedArgs) {
processOnSortChanged(event: Event, args: SortChangedArgs) {
const sortColumns = (args.multiColumnSort) ? args.sortCols : new Array({ sortCol: args.sortCol, sortAsc: args.sortAsc });

// loop through all columns to inspect sorters & set the query
Expand Down
Expand Up @@ -119,7 +119,7 @@ export class GridOdataService implements BackendService {
/*
* FILTERING
*/
onFilterChanged(event: Event, args: FilterChangedArgs): Promise<string> {
processOnFilterChanged(event: Event, args: FilterChangedArgs): Promise<string> {
const serviceOptions: GridOption = args.grid.getOptions();
const backendApi = serviceOptions.backendServiceApi;

Expand Down Expand Up @@ -152,7 +152,7 @@ export class GridOdataService implements BackendService {
/*
* PAGINATION
*/
onPaginationChanged(event: Event, args: PaginationChangedArgs) {
processOnPaginationChanged(event: Event, args: PaginationChangedArgs) {
const pageSize = +(args.pageSize || DEFAULT_PAGE_SIZE);
this.updatePagination(args.newPage, pageSize);

Expand All @@ -163,7 +163,7 @@ export class GridOdataService implements BackendService {
/*
* SORTING
*/
onSortChanged(event: Event, args: SortChangedArgs) {
processOnSortChanged(event: Event, args: SortChangedArgs) {
const sortColumns = (args.multiColumnSort) ? args.sortCols : new Array({ sortCol: args.sortCol, sortAsc: args.sortAsc });

// loop through all columns to inspect sorters & set the query
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/angular-slickgrid/services/sort.service.ts
Expand Up @@ -65,7 +65,7 @@ export class SortService {
if (backendApi.preProcess) {
backendApi.preProcess();
}
const query = backendApi.service.onSortChanged(event, args);
const query = backendApi.service.processOnSortChanged(event, args);
this.emitSortChanged('remote');

// the process could be an Observable (like HttpClient) or a Promise
Expand Down

0 comments on commit 9650568

Please sign in to comment.