mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-08 18:23:13 +08:00
Added stubs for some native modules
Reviewed By: javache Differential Revision: D5111649 fbshipit-source-id: eef2f84556611dec01978d845b89fa145ec5d4db
This commit is contained in:
committed by
Facebook Github Bot
parent
bd5051adeb
commit
a93b7a2da0
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const FormData = require('FormData');
|
||||
const MissingNativeEventEmitterShim = require('MissingNativeEventEmitterShim');
|
||||
const NativeEventEmitter = require('NativeEventEmitter');
|
||||
const RCTNetworkingNative = require('NativeModules').Networking;
|
||||
const convertRequestBody = require('convertRequestBody');
|
||||
@@ -20,6 +20,8 @@ import type {RequestBody} from 'convertRequestBody';
|
||||
|
||||
class RCTNetworking extends NativeEventEmitter {
|
||||
|
||||
isAvailable: boolean = true;
|
||||
|
||||
constructor() {
|
||||
super(RCTNetworkingNative);
|
||||
}
|
||||
@@ -58,4 +60,31 @@ class RCTNetworking extends NativeEventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new RCTNetworking();
|
||||
if (__DEV__ && !RCTNetworkingNative) {
|
||||
class MissingNativeRCTNetworkingShim extends MissingNativeEventEmitterShim {
|
||||
constructor() {
|
||||
super('RCTAppState', 'AppState');
|
||||
}
|
||||
|
||||
sendRequest(...args: Array<any>) {
|
||||
this.throwMissingNativeModule();
|
||||
}
|
||||
|
||||
abortRequest(...args: Array<any>) {
|
||||
this.throwMissingNativeModule();
|
||||
}
|
||||
|
||||
clearCookies(...args: Array<any>) {
|
||||
this.throwMissingNativeModule();
|
||||
}
|
||||
}
|
||||
|
||||
// This module depends on the native `RCTNetworkingNative` module. If you don't include it,
|
||||
// `RCTNetworking.isAvailable` will return `false`, and any method calls will throw.
|
||||
// We reassign the class variable to keep the autodoc generator happy.
|
||||
RCTNetworking = new MissingNativeRCTNetworkingShim();
|
||||
} else {
|
||||
RCTNetworking = new RCTNetworking();
|
||||
}
|
||||
|
||||
module.exports = RCTNetworking;
|
||||
|
||||
Reference in New Issue
Block a user