From b4cdbef593222408d655f9a57fe4ade7793bae1a Mon Sep 17 00:00:00 2001 From: Salakar Date: Thu, 17 Aug 2017 17:25:13 +0100 Subject: [PATCH] [js][internals] _NATIVE_MODULE mapping for `nativeModuleExists` --- lib/firebase-app.js | 2 +- lib/firebase.js | 5 +++-- lib/modules/admob/index.js | 6 ++++-- lib/modules/config/index.js | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/firebase-app.js b/lib/firebase-app.js index 4abfeab2..822616a8 100644 --- a/lib/firebase-app.js +++ b/lib/firebase-app.js @@ -129,7 +129,7 @@ export default class FirebaseApp { }; Object.assign(getInstance, statics, { - nativeModuleExists: !!NativeModules[`RNFirebase${capitalizeFirstLetter(name)}`], + nativeModuleExists: !!NativeModules[`RNFirebase${InstanceClass._NATIVE_MODULE || capitalizeFirstLetter(name)}`], }); return getInstance; diff --git a/lib/firebase.js b/lib/firebase.js index 97f3fd2a..7c7f1569 100644 --- a/lib/firebase.js +++ b/lib/firebase.js @@ -201,10 +201,11 @@ class FirebaseCore { * * @param namespace * @param statics + * @param InstanceClass * @return {function(FirebaseApp=)} * @private */ - _appNamespaceOrStatics(namespace, statics = {}): Function { + _appNamespaceOrStatics(namespace, statics = {}, InstanceClass): Function { const getNamespace = (app?: FirebaseApp) => { let _app = app; // throw an error if it's not a valid app instance @@ -217,7 +218,7 @@ class FirebaseCore { }; Object.assign(getNamespace, statics, { - nativeModuleExists: !!NativeModules[`RNFirebase${capitalizeFirstLetter(namespace)}`], + nativeModuleExists: !!NativeModules[`RNFirebase${InstanceClass._NATIVE_MODULE || capitalizeFirstLetter(namespace)}`], }); return getNamespace; } diff --git a/lib/modules/admob/index.js b/lib/modules/admob/index.js index 78b638d0..1961cc42 100644 --- a/lib/modules/admob/index.js +++ b/lib/modules/admob/index.js @@ -8,9 +8,11 @@ import Banner from './Banner'; import NativeExpress from './NativeExpress'; -export default class Admob extends ModuleBase { +export default class AdMob extends ModuleBase { + static _NATIVE_MODULE = 'AdMob'; + constructor(firebaseApp: Object, options: Object = {}) { - super(firebaseApp, options, 'AdMob', true); + super(firebaseApp, options, AdMob._NATIVE_MODULE, true); this._initialized = false; this._appId = null; diff --git a/lib/modules/config/index.js b/lib/modules/config/index.js index c7e001df..28f7f6c8 100644 --- a/lib/modules/config/index.js +++ b/lib/modules/config/index.js @@ -7,8 +7,9 @@ import ModuleBase from './../../utils/ModuleBase'; * @class Config */ export default class RemoteConfig extends ModuleBase { + static _NATIVE_MODULE = 'RemoteConfig'; constructor(firebaseApp: Object, options: Object = {}) { - super(firebaseApp, options, 'RemoteConfig'); + super(firebaseApp, options, RemoteConfig._NATIVE_MODULE); this.developerModeEnabled = false; }