Custom Backend Service
Intro
Instructions
class MyComponent {
gridInit() {
this.gridOptions = {
backendServiceApi: {
service: new YourCustomBackendService(),
options: {
// custom service options that extends "backendServiceOption" interface
},
preProcess: () => !this.isDataLoaded ? this.displaySpinner(true) : '',
process: (query, options) => this.getCountries(query, options),
postProcess: (result) => {
this.displaySpinner(false);
this.isDataLoaded = true;
}
} as YourCustomBackendServiceApi
};
}
// Note: The second parameter contains the AbortSignal for an optional request cancellation
getCountries(query: string, options?: { signal?: AbortSignal }) {
// You can pass the signal to fetch or other HTTP libraries
return fetch(`/api/countries?${query}`, {
signal: options?.signal // Pass the signal to enable automatic request cancellation
});
}
}Request Cancellation with AbortSignal
Why Cancellation is Important
How It Works
Implementation
Important Notes
Last updated