mirror of
https://github.com/status-im/react-native-firebase.git
synced 2026-08-31 06:01:09 +00:00
[internals] More tidy up and hiding of internal functions
This commit is contained in:
+17
-26
@@ -1,27 +1,16 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
import { initialiseNativeModuleEventEmitter } from './events';
|
||||
import { getNativeModule, initialiseNativeModule } from './native';
|
||||
import { initialiseLogger } from './log';
|
||||
import { initialiseNativeModule } from './native';
|
||||
|
||||
import type FirebaseApp from '../modules/core/firebase-app';
|
||||
import type { FirebaseModuleName } from '../types';
|
||||
|
||||
const DEFAULTS = {
|
||||
Database: {
|
||||
persistence: false,
|
||||
},
|
||||
};
|
||||
import type { FirebaseModuleConfig } from '../types';
|
||||
|
||||
export default class ModuleBase {
|
||||
_native: Object;
|
||||
_module: string;
|
||||
_options: Object;
|
||||
_appName: string;
|
||||
_namespace: string;
|
||||
_firebaseApp: FirebaseApp;
|
||||
static _NAMESPACE: FirebaseModuleName;
|
||||
static _NATIVE_MODULE: string;
|
||||
_native: Object;
|
||||
_options: Object;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,19 +18,21 @@ export default class ModuleBase {
|
||||
* @param options
|
||||
* @param withEventEmitter
|
||||
*/
|
||||
constructor(firebaseApp: FirebaseApp, options: Object, events: string[] = []) {
|
||||
this._module = this.constructor._NATIVE_MODULE.replace('RNFirebase', '');
|
||||
constructor(firebaseApp: FirebaseApp, options: Object, config: FirebaseModuleConfig) {
|
||||
if (!config.moduleName) {
|
||||
throw new Error('Missing module name');
|
||||
}
|
||||
if (!config.namespace) {
|
||||
throw new Error('Missing namespace');
|
||||
}
|
||||
const { moduleName } = config;
|
||||
this._firebaseApp = firebaseApp;
|
||||
this._appName = firebaseApp._name;
|
||||
this._namespace = `${this._appName}:${this._module}`;
|
||||
this._options = Object.assign({}, DEFAULTS[this._module] || {}, options);
|
||||
this._options = options;
|
||||
|
||||
// check if native module exists as all native
|
||||
initialiseNativeModule(this);
|
||||
// TODO: Get rid of
|
||||
this._native = getNativeModule(this);
|
||||
|
||||
initialiseNativeModuleEventEmitter(this, events);
|
||||
// TODO: Get rid of this._native and change to using getNativeModule instead?
|
||||
this._native = initialiseNativeModule(this, config);
|
||||
initialiseLogger(this, `${firebaseApp.name}:${moduleName.replace('RNFirebase', '')}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user