[js][core] added `nativeModuleExists` property to all module statics - true or false if the native android/ios module is present

This commit is contained in:
Salakar 2017-08-15 17:28:51 +01:00
parent e3f0213aaa
commit 67985f8e90
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { NativeModules } from 'react-native';
import INTERNALS from './internals';
import { capitalizeFirstLetter } from './utils';
import AdMob, { statics as AdMobStatics } from './modules/admob';
import Auth, { statics as AuthStatics } from './modules/auth';
@ -127,7 +128,9 @@ export default class FirebaseApp {
return this._namespaces[_name];
};
Object.assign(getInstance, statics);
Object.assign(getInstance, statics, {
nativeModuleExists: !!NativeModules[`RNFirebase${capitalizeFirstLetter(name)}`],
});
return getInstance;
}
}

View File

@ -4,7 +4,7 @@
*/
import { NativeModules, NativeEventEmitter } from 'react-native';
import { isObject, isString } from './utils';
import { isObject, isString, capitalizeFirstLetter } from './utils';
import INTERNALS from './internals';
import PACKAGE from './../package.json';
@ -216,7 +216,9 @@ class FirebaseCore {
return INTERNALS.APPS[_app.name][namespace](_app);
};
Object.assign(getNamespace, statics);
Object.assign(getNamespace, statics, {
nativeModuleExists: !!NativeModules[`RNFirebase${capitalizeFirstLetter(namespace)}`],
});
return getNamespace;
}