2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

fix(fetch): optimize signals composing logic; (#6582)

This commit is contained in:
Dmitriy Mozgovoy
2024-08-30 21:26:12 +03:00
committed by GitHub
parent ee208cfcae
commit df9889b83c
4 changed files with 101 additions and 49 deletions
+14
View File
@@ -102,6 +102,20 @@ class CancelToken {
}
}
toAbortSignal() {
const controller = new AbortController();
const abort = (err) => {
controller.abort(err);
};
this.subscribe(abort);
controller.signal.unsubscribe = () => this.unsubscribe(abort);
return controller.signal;
}
/**
* Returns an object that contains a new `CancelToken` and a function that, when called,
* cancels the `CancelToken`.