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 Promise-based request cancellation.
// Since Angular HttpClient returns RxJS Observables, it uses its own cancellation mechanism.
// If you want to use AbortSignal, use the Fetch API instead.
getCountries(query: string, options?: { signal?: AbortSignal }) {
// Using Angular HttpClient (RxJS Observable - has built-in cancellation)
return this.http.get(`/api/countries?${query}`, {
reportProgress: true
});
// Alternative: Use Fetch API for AbortSignal support
// return fetch(`/api/countries?${query}`, {
// signal: options?.signal
// }).then(response => response.json());
}
}Request Cancellation with AbortSignal
Why Cancellation is Important
How It Works
Implementation
Important Notes
Last updated