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
ghiscoding committed May 26, 2018
1 parent da163bb commit 0bf9d94
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,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 | null, args: SortChangedArgs) => string;
processOnSortChanged: (event: Event | null, args: SortChangedArgs) => string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,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 @@ -310,7 +310,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 @@ -323,7 +323,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
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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 @@ -159,7 +159,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 @@ -170,7 +170,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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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');

// await for the Promise to resolve the data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class SlickPaginationCustomElement {
backendApi.preProcess();
}

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

// await for the Promise to resolve the data
const processResult = await backendApi.process(query);
Expand Down

0 comments on commit 0bf9d94

Please sign in to comment.