mirror of
https://github.com/status-im/react-native-firebase.git
synced 2026-08-31 14:11:12 +00:00
[js][internals] _NAMESPACE & _NATIVE_MODULE static props for all modules
This commit is contained in:
@@ -46,31 +46,31 @@ export default class ModuleBase {
|
||||
* @param moduleName
|
||||
* @param withEventEmitter
|
||||
*/
|
||||
constructor(firebaseApp, options, moduleName, withEventEmitter = false) {
|
||||
this._module = moduleName;
|
||||
constructor(firebaseApp, options, withEventEmitter = false) {
|
||||
this._module = this.constructor._NATIVE_MODULE.replace('RNFirebase', '');
|
||||
this._firebaseApp = firebaseApp;
|
||||
this._appName = firebaseApp._name;
|
||||
this._namespace = `${this._appName}:${this._module}`;
|
||||
this._options = Object.assign({}, DEFAULTS[moduleName] || {}, options);
|
||||
this._options = Object.assign({}, DEFAULTS[this._module] || {}, options);
|
||||
|
||||
// check if native module exists as all native
|
||||
// modules are now optionally part of build
|
||||
const nativeModule = NativeModules[`RNFirebase${moduleName}`];
|
||||
const nativeModule = NativeModules[this.constructor._NATIVE_MODULE];
|
||||
|
||||
if (!nativeModule) {
|
||||
throw new Error(INTERNALS.STRINGS.ERROR_MISSING_MODULE(moduleName));
|
||||
throw new Error(INTERNALS.STRINGS.ERROR_MISSING_MODULE(this.constructor._NATIVE_MODULE));
|
||||
}
|
||||
|
||||
// used by the modules that extend ModuleBase
|
||||
// to access their native module counterpart
|
||||
if (!MULTI_APP_MODULES.includes(moduleName.toLowerCase())) {
|
||||
if (!MULTI_APP_MODULES.includes(this._module.toLowerCase())) {
|
||||
this._native = nativeModule;
|
||||
} else {
|
||||
this._native = nativeWithApp(this._appName, nativeModule);
|
||||
}
|
||||
|
||||
if (withEventEmitter) {
|
||||
this._setupEventEmitter(nativeModule, moduleName);
|
||||
this._setupEventEmitter(nativeModule, this._module);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user