Skip to content

Commit

Permalink
docs: document abort controllers
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler J Russell <22531310+Nytelife26@users.noreply.github.com>
  • Loading branch information
tbnritzdoge and Nytelife26 committed Apr 12, 2021
1 parent 5ddde36 commit 9ee59d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/PetitioRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,14 @@ export class PetitioRequest {
return this;
}
/**
* @param {AbortController} controller A AbortController to potentially abort the request.
* @param {AbortController} controller A controller instance that handles aborting the request.
* @return {*} The request object for further composition.
* @example
* ```ts
* const controller = new AbortController();
* const result = petitio(URL).signal(controller);
* setTimeout(() => controller.abort(), 5000) // serves as a request timeout
* ```
*/
public signal(controller: AbortController): this {
this.controller = controller;
Expand Down

0 comments on commit 9ee59d1

Please sign in to comment.