We are developing a frontend application utilizing @c8y/client for seamless interaction with the Cumulocity APIs. To maintain optimal performance, we aim to abort any pending requests when a user navigates from one dashboard to another.
We frequently encounter the following situation and seek a solution:
Dashboard A is loaded, initiating multiple requests to the platform for data retrieval.
Before all requests from Dashboard A are completed, the user navigates to Dashboard B.
Dashboard B starts its own data requests, but due to the pending requests from Dashboard A, there are unnecessary delays.
In a single-page application, the browser prioritizes finishing requests from Dashboard A before starting those for Dashboard B, causing longer load times.
Our research indicates that the "AbortController" is supported by all major browsers and offers the functionality we need to address this issue.
Implementing this feature would be a valuable addition to the SDK, significantly enhancing user experience by reducing load times.
Hi Arne,
This should already be possible by defining your own authentication strategy. Each strategy has a
getFetchOptions
method that you can overwrite. E.g.class AbortableCookieAuth extends CookieAuth {
getFetchOptions(options) {
const controller = new AbortController();
const signal = controller.signal;
options.signal = signal;
return options;
}
}
Note: This is only pseudo code and has not been tested, but this is how to align the fetch options.
I hope this helps.
Regards
Jan