Permalink
Browse files

inline a bunch of NativeModule requires

Reviewed By: shergin

Differential Revision: D4578180

fbshipit-source-id: 3764ffd32eb7e4698e928740bc72bbad02876894
  • Loading branch information...
AaaChiuuu authored and facebook-github-bot committed Feb 18, 2017
1 parent dc0df40 commit 1fa95ed390d96b4a54702acdf89594af1785a3fd
View
@@ -11,9 +11,9 @@
*/
'use strict';
var AlertIOS = require('AlertIOS');
var Platform = require('Platform');
var DialogModuleAndroid = require('NativeModules').DialogManagerAndroid;
const AlertIOS = require('AlertIOS');
const NativeModules = require('NativeModules');
const Platform = require('Platform');
import type { AlertType, AlertButtonStyle } from 'AlertIOS';
@@ -127,18 +127,18 @@ class AlertAndroid {
if (buttonPositive) {
config = {...config, buttonPositive: buttonPositive.text || '' };
}
DialogModuleAndroid.showAlert(
NativeModules.DialogModuleAndroid.showAlert(
config,
(errorMessage) => console.warn(errorMessage),
(action, buttonKey) => {
if (action !== DialogModuleAndroid.buttonClicked) {
if (action !== NativeModules.DialogModuleAndroid.buttonClicked) {
return;
}
if (buttonKey === DialogModuleAndroid.buttonNeutral) {
if (buttonKey === NativeModules.DialogModuleAndroid.buttonNeutral) {
buttonNeutral.onPress && buttonNeutral.onPress();
} else if (buttonKey === DialogModuleAndroid.buttonNegative) {
} else if (buttonKey === NativeModules.DialogModuleAndroid.buttonNegative) {
buttonNegative.onPress && buttonNegative.onPress();
} else if (buttonKey === DialogModuleAndroid.buttonPositive) {
} else if (buttonKey === NativeModules.DialogModuleAndroid.buttonPositive) {
buttonPositive.onPress && buttonPositive.onPress();
}
}
@@ -10,14 +10,14 @@
*/
'use strict';
var DialogManager = require('NativeModules').DialogManagerAndroid;
var NativeModules = require('NativeModules');
function emptyCallback() {}
module.exports = {
alertWithArgs: function(args, callback) {
// TODO(5998984): Polyfill it correctly with DialogManagerAndroid
DialogManager.showAlert(
NativeModules.DialogManagerAndroid.showAlert(
args,
emptyCallback,
callback || emptyCallback);
@@ -13,17 +13,17 @@
*/
'use strict';
import type { ResolvedAssetSource } from 'AssetSourceResolver';
const AssetRegistry = require('AssetRegistry');
const AssetSourceResolver = require('AssetSourceResolver');
const { SourceCode } = require('NativeModules');
const NativeModules = require('NativeModules');
import type { ResolvedAssetSource } from 'AssetSourceResolver';
let _customSourceTransformer, _serverURL, _bundleSourcePath;
function getDevServerURL(): ?string {
if (_serverURL === undefined) {
var scriptURL = SourceCode.scriptURL;
var scriptURL = NativeModules.SourceCode.scriptURL;
var match = scriptURL && scriptURL.match(/^https?:\/\/.*?\//);
if (match) {
// Bundle was loaded from network
@@ -38,7 +38,7 @@ function getDevServerURL(): ?string {
function getBundleSourcePath(): ?string {
if (_bundleSourcePath === undefined) {
const scriptURL = SourceCode.scriptURL;
const scriptURL = NativeModules.SourceCode.scriptURL;
if (!scriptURL) {
// scriptURL is falsy, we have nothing to go on here
_bundleSourcePath = null;
@@ -11,12 +11,11 @@
*/
'use strict';
const DialogManagerAndroid = require('NativeModules').DialogManagerAndroid;
const Permissions = require('NativeModules').PermissionsAndroid;
const NativeModules = require('NativeModules');
type Rationale = {
title: string;
message: string;
title: string,
message: string,
}
type PermissionStatus = 'granted' | 'denied' | 'never_ask_again';
@@ -113,15 +112,15 @@ class PermissionsAndroid {
*/
checkPermission(permission: string) : Promise<boolean> {
console.warn('"PermissionsAndroid.checkPermission" is deprecated. Use "PermissionsAndroid.check" instead');
return Permissions.checkPermission(permission);
return NativeModules.PermissionsAndroid.checkPermission(permission);
}
/**
* Returns a promise resolving to a boolean value as to whether the specified
* permissions has been granted
*/
check(permission: string) : Promise<boolean> {
return Permissions.checkPermission(permission);
return NativeModules.PermissionsAndroid.checkPermission(permission);
}
/**
@@ -156,19 +155,19 @@ class PermissionsAndroid {
*/
async request(permission: string, rationale?: Rationale) : Promise<PermissionStatus> {
if (rationale) {
const shouldShowRationale = await Permissions.shouldShowRequestPermissionRationale(permission);
const shouldShowRationale = await NativeModules.PermissionsAndroid.shouldShowRequestPermissionRationale(permission);
if (shouldShowRationale) {
return new Promise((resolve, reject) => {
DialogManagerAndroid.showAlert(
NativeModules.DialogManagerAndroid.showAlert(
rationale,
() => reject(new Error('Error showing rationale')),
() => resolve(Permissions.requestPermission(permission))
() => resolve(NativeModules.PermissionsAndroid.requestPermission(permission))
);
});
}
}
return Permissions.requestPermission(permission);
return NativeModules.PermissionsAndroid.requestPermission(permission);
}
/**
@@ -177,7 +176,7 @@ class PermissionsAndroid {
* indicating whether the user allowed or denied the request
*/
requestMultiple(permissions: Array<string>) : Promise<{[permission: string]: PermissionStatus}> {
return Permissions.requestMultiplePermissions(permissions);
return NativeModules.PermissionsAndroid.requestMultiplePermissions(permissions);
}
}
@@ -13,14 +13,13 @@
const BatchedBridge = require('BatchedBridge');
const BugReporting = require('BugReporting');
const NativeModules = require('NativeModules');
const ReactNative = require('ReactNative');
const infoLog = require('infoLog');
const invariant = require('fbjs/lib/invariant');
const renderApplication = require('renderApplication');
const { HeadlessJsTaskSupport } = require('NativeModules');
if (__DEV__) {
// In order to use Cmd+P to record/dump perf data, we need to make sure
// this module is available in the bundle
@@ -188,10 +187,10 @@ const AppRegistry = {
throw new Error(`No task registered for key ${taskKey}`);
}
taskProvider()(data)
.then(() => HeadlessJsTaskSupport.notifyTaskFinished(taskId))
.then(() => NativeModules.HeadlessJsTaskSupport.notifyTaskFinished(taskId))
.catch(reason => {
console.error(reason);
HeadlessJsTaskSupport.notifyTaskFinished(taskId);
NativeModules.HeadlessJsTaskSupport.notifyTaskFinished(taskId);
});
}
@@ -13,13 +13,12 @@
*/
'use strict';
var NativeModules = require('NativeModules');
var RCTAsyncSQLiteStorage = NativeModules.AsyncSQLiteDBStorage;
var RCTAsyncRocksDBStorage = NativeModules.AsyncRocksDBStorage;
var RCTAsyncFileStorage = NativeModules.AsyncLocalStorage;
const NativeModules = require('NativeModules');
// Use RocksDB if available, then SQLite, then file storage.
var RCTAsyncStorage = RCTAsyncRocksDBStorage || RCTAsyncSQLiteStorage || RCTAsyncFileStorage;
const RCTAsyncStorage = NativeModules.AsyncSQLiteDBStorage ||

This comment has been minimized.

Show comment
Hide comment
@chirag04

chirag04 Feb 18, 2017

Collaborator

@AaaChiuuu this changes the order and contradicts the comment about using RocksDB first.

@chirag04

chirag04 Feb 18, 2017

Collaborator

@AaaChiuuu this changes the order and contradicts the comment about using RocksDB first.

This comment has been minimized.

Show comment
Hide comment
@AaaChiuuu

AaaChiuuu Feb 18, 2017

Contributor

dang, i thought i fixed that before landing. will put up another diff

@AaaChiuuu

AaaChiuuu Feb 18, 2017

Contributor

dang, i thought i fixed that before landing. will put up another diff

NativeModules.AsyncRocksDBStorage ||
NativeModules.AsyncLocalStorage;
/**
* @class

0 comments on commit 1fa95ed

Please sign in to comment.