[js] remove old code
This commit is contained in:
parent
d9023f55b8
commit
2c2766f767
|
@ -2,7 +2,7 @@
|
|||
* @providesModule Firebase
|
||||
* @flow
|
||||
*/
|
||||
import { NativeModules, NativeEventEmitter } from 'react-native';
|
||||
import { NativeModules } from 'react-native';
|
||||
|
||||
import Log from './utils/log';
|
||||
import { isObject } from './utils';
|
||||
|
@ -17,7 +17,6 @@ import Crash from './modules/crash';
|
|||
|
||||
const instances = { default: null };
|
||||
const FirebaseModule = NativeModules.RNFirebase;
|
||||
const FirebaseModuleEvt = new NativeEventEmitter(FirebaseModule);
|
||||
|
||||
/**
|
||||
* @class Firebase
|
||||
|
@ -59,30 +58,6 @@ export default class Firebase {
|
|||
this.database = this._staticsOrInstance('database', DatabaseStatics, Database);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param statics
|
||||
* @param InstanceClass
|
||||
* @returns {function()}
|
||||
* @private
|
||||
*/
|
||||
_staticsOrInstance(name, statics, InstanceClass) {
|
||||
const getInstance = () => {
|
||||
const internalPropName = `_${name}`;
|
||||
|
||||
if (!this[internalPropName]) {
|
||||
this[internalPropName] = new InstanceClass(this);
|
||||
}
|
||||
|
||||
return this[internalPropName];
|
||||
};
|
||||
|
||||
Object.assign(getInstance, statics || {});
|
||||
|
||||
return getInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support web version of initApp.
|
||||
* @param options
|
||||
|
@ -106,13 +81,6 @@ export default class Firebase {
|
|||
return instances[name];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrappers
|
||||
* We add methods from each wrapper to this instance
|
||||
* when they are needed. Not sure if this is a good
|
||||
* idea or not (imperative vs. direct manipulation/proxy)
|
||||
*/
|
||||
auth() {
|
||||
return this._auth;
|
||||
}
|
||||
|
@ -159,36 +127,26 @@ export default class Firebase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Redux store
|
||||
**/
|
||||
get store(): ?Object {
|
||||
return this._store;
|
||||
}
|
||||
|
||||
get constants(): Object {
|
||||
if (!this._constants) {
|
||||
this._constants = Object.assign({}, Storage.constants);
|
||||
}
|
||||
return this._constants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global event handlers for the single Firebase instance
|
||||
*
|
||||
* @param name
|
||||
* @param statics
|
||||
* @param InstanceClass
|
||||
* @returns {function()}
|
||||
* @private
|
||||
*/
|
||||
on(name: string, cb: Function, nativeModule: Object = FirebaseModuleEvt) {
|
||||
if (!this.eventHandlers[name]) {
|
||||
this.eventHandlers[name] = [];
|
||||
_staticsOrInstance(name, statics, InstanceClass) {
|
||||
const getInstance = () => {
|
||||
const internalPropName = `_${name}`;
|
||||
|
||||
if (!this[internalPropName]) {
|
||||
this[internalPropName] = new InstanceClass(this);
|
||||
}
|
||||
|
||||
const sub = nativeModule.addListener(name, cb);
|
||||
this.eventHandlers[name].push(sub);
|
||||
return sub;
|
||||
}
|
||||
return this[internalPropName];
|
||||
};
|
||||
|
||||
off(name: string) {
|
||||
if (this.eventHandlers[name]) {
|
||||
this.eventHandlers[name]
|
||||
.forEach(subscription => subscription.remove());
|
||||
}
|
||||
Object.assign(getInstance, statics || {});
|
||||
|
||||
return getInstance;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue