Skip to content

Commit

Permalink
chore: remove abort controller polyfill (#251)
Browse files Browse the repository at this point in the history
* chore: remove abort controller polyfill

* test: update test case and remove AbortController export

* docs: update doc for abort controller
  • Loading branch information
ttys026 authored May 25, 2021
1 parent f86c873 commit 17867b5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 29 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@ clientB.interceptors.request.use(
Base on [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) that allows you to abort one or more Web requests as and when desired.

```javascript
import Request, { AbortController } from 'umi-request';
// polyfill abort controller if needed
import 'yet-another-abortcontroller-polyfill'
import Request from 'umi-request';

const controller = new AbortController(); // create a controller
const { signal } = controller; // grab a reference to its associated AbortSignal object using the AbortController.signal property
Expand Down
4 changes: 3 additions & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ clientB.interceptors.request.use(
基于 [AbortController](https://developer.mozilla.org/zh-CN/docs/Web/API/FetchController) 方案来中止一个或多个DOM请求

```javascript
import Request, { AbortController } from 'umi-request';
// 按需决定是否使用 polyfill
import 'yet-another-abortcontroller-polyfill'
import Request from 'umi-request';

const controller = new AbortController(); // 创建一个控制器
const { signal } = controller; // 返回一个 AbortSignal 对象实例,它可以用来 with/abort 一个 DOM 请求。
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"whatwg-fetch": "^3.0.0"
},
"dependencies": {
"abort-controller": "^3.0.0",
"isomorphic-fetch": "^2.2.1",
"qs": "^6.9.1"
},
Expand Down
22 changes: 0 additions & 22 deletions src/cancel/abortControllerCancel.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import request, { extend, fetch } from './request';
import Onion from './onion';
import { RequestError, ResponseError } from './utils';
import { AbortController, AbortSignal } from './cancel/abortControllerCancel';

export { extend, RequestError, ResponseError, Onion, fetch, AbortController, AbortSignal };
export { extend, RequestError, ResponseError, Onion, fetch };

export default request;
4 changes: 2 additions & 2 deletions test/cancel/abortControllerCancel.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import createTestServer from 'create-test-server';
import request, { AbortController } from '../../src/index';
import request from '../../src/index';

const writeData = (data, res) => {
res.setHeader('access-control-allow-origin', '*');
Expand All @@ -17,7 +17,7 @@ describe('test abortController', () => {
server.close();
});

const prefix = api => `${server.url}${api}`;
const prefix = (api) => `${server.url}${api}`;

jest.useFakeTimers();

Expand Down

0 comments on commit 17867b5

Please sign in to comment.