[REQ] Support AbortController in Typescript-Fetch
Created by: rahulsom
Is your feature request related to a problem? Please describe.
The Fetch API supports attaching a signal, and using that to abort requests. This is particularly helpful when building SPAs which background a lot of requests, and the user navigates to an area of the app where some requests are no longer useful. It improves performance for the user if we can cancel pending requests so newer requests can execute sooner.
Describe the solution you'd like
Currently, this is what generated code looks like when using single param
async methodName(requestParameters: RequestType): Promise<ResponseType> {...}
interface RequestType {
fieldName1: FieldType1;
fieldName2: FieldType2;
}
Support either of these two methods
async methodName(requestParameters: RequestType, abortController?: AbortController): Promise<ResponseType> {...}
interface RequestType {
fieldName1: FieldType1;
fieldName2: FieldType2;
}
or
async methodName(requestParameters: RequestType): Promise<ResponseType> {...}
interface RequestType {
fieldName1: FieldType1;
fieldName2: FieldType2;
abortController: AbortController;
}
This library seems to be commonly used for this purpose - https://github.com/mysticatea/abort-controller
Describe alternatives you've considered
I can't think of an alternative.
Additional context
None.