mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-14 02:24:43 +08:00
Summary: This adds https://github.com/mysticatea/abort-controller to polyfill [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). This is used to cancel requests when using `fetch`. This also updates `event-target-shim` to 5.0 to make sure we only have one version of this dependency. This updates required adding a polyfill for `console.assert` which is used by the new version. I made one based on https://github.com/gskinner/console-polyfill/blob/master/console.js#L74. The polyfill is very small, especially since we already use `event-target-shim` so I think it makes sense to include in core. Depends on #24418 so that the fetch polyfill supports the `signal` parameter. Fixes #18115 [General] [Added] - Add support for cancelling fetch requests with AbortController Pull Request resolved: https://github.com/facebook/react-native/pull/24419 Differential Revision: D14912858 Pulled By: cpojer fbshipit-source-id: 8a6402910398db51e2f3e3262f07aabdf68fcf72
72 lines
1.6 KiB
JavaScript
72 lines
1.6 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const React = require('react');
|
|
|
|
const XHRExampleDownload = require('./XHRExampleDownload');
|
|
const XHRExampleBinaryUpload = require('./XHRExampleBinaryUpload');
|
|
const XHRExampleFormData = require('./XHRExampleFormData');
|
|
const XHRExampleHeaders = require('./XHRExampleHeaders');
|
|
const XHRExampleFetch = require('./XHRExampleFetch');
|
|
const XHRExampleOnTimeOut = require('./XHRExampleOnTimeOut');
|
|
const XHRExampleAbortController = require('./XHRExampleAbortController');
|
|
|
|
exports.framework = 'React';
|
|
exports.title = 'XMLHttpRequest';
|
|
exports.description =
|
|
'Example that demonstrates upload and download ' +
|
|
'requests using XMLHttpRequest.';
|
|
exports.examples = [
|
|
{
|
|
title: 'File Download',
|
|
render() {
|
|
return <XHRExampleDownload />;
|
|
},
|
|
},
|
|
{
|
|
title: 'multipart/form-data Upload',
|
|
render() {
|
|
return <XHRExampleBinaryUpload />;
|
|
},
|
|
},
|
|
{
|
|
title: 'multipart/form-data Upload',
|
|
render() {
|
|
return <XHRExampleFormData />;
|
|
},
|
|
},
|
|
{
|
|
title: 'Fetch Test',
|
|
render() {
|
|
return <XHRExampleFetch />;
|
|
},
|
|
},
|
|
{
|
|
title: 'Headers',
|
|
render() {
|
|
return <XHRExampleHeaders />;
|
|
},
|
|
},
|
|
{
|
|
title: 'Time Out Test',
|
|
render() {
|
|
return <XHRExampleOnTimeOut />;
|
|
},
|
|
},
|
|
{
|
|
title: 'Abort Test',
|
|
render() {
|
|
return <XHRExampleAbortController />;
|
|
},
|
|
},
|
|
];
|