[flow] fixed flow errors in ModuleBase

This commit is contained in:
Salakar 2017-09-25 15:38:54 +01:00
parent 1e4968d9c7
commit 3f681ac065
1 changed files with 23 additions and 12 deletions

View File

@ -2,10 +2,12 @@
* @flow
*/
import { NativeModules } from 'react-native';
import Log from '../utils/log';
import { nativeWithApp } from './../utils';
import INTERNALS from './../internals';
import FirebaseCore from './../firebase';
import FirebaseApp from '../firebase-app';
import { nativeWithApp } from './../utils';
const logs = {};
@ -37,14 +39,23 @@ const DEFAULTS = {
};
export default class ModuleBase {
_native: Object;
_module: string;
_options: Object;
_appName: string;
_namespace: string;
_firebaseApp: Object;
_eventEmitter: Object;
static _NAMESPACE: string;
static _NATIVE_MODULE: string;
/**
*
* @param firebaseApp
* @param options
* @param moduleName
* @param withEventEmitter
*/
constructor(firebaseApp, options, withEventEmitter = false) {
constructor(firebaseApp: Object, options: Object, withEventEmitter: boolean = false) {
this._module = this.constructor._NATIVE_MODULE.replace('RNFirebase', '');
this._firebaseApp = firebaseApp;
this._appName = firebaseApp._name;
@ -108,7 +119,7 @@ export default class ModuleBase {
* Returns the FirebaseApp instance for current module
* @return {*}
*/
get app() {
get app(): FirebaseApp {
return this._firebaseApp;
}
@ -123,27 +134,27 @@ export default class ModuleBase {
* Proxy functions to shared event emitter instance
* https://github.com/facebook/react-native/blob/master/Libraries/EventEmitter/EventEmitter.js
*/
get sharedEventEmitter() {
get sharedEventEmitter(): Object {
return INTERNALS.SharedEventEmitter;
}
get addListener() {
get addListener(): Function {
return INTERNALS.SharedEventEmitter.addListener.bind(INTERNALS.SharedEventEmitter);
}
get once() {
get once(): Function {
return INTERNALS.SharedEventEmitter.once.bind(INTERNALS.SharedEventEmitter);
}
get on() {
get on(): Function {
return INTERNALS.SharedEventEmitter.addListener.bind(INTERNALS.SharedEventEmitter);
}
get emit() {
get emit(): Function {
return INTERNALS.SharedEventEmitter.emit.bind(INTERNALS.SharedEventEmitter);
}
get listeners() {
get listeners(): Function {
return INTERNALS.SharedEventEmitter.listeners.bind(INTERNALS.SharedEventEmitter);
}
@ -152,11 +163,11 @@ export default class ModuleBase {
return subscriptions && subscriptions.length;
}
get removeListener() {
get removeListener(): Function {
return INTERNALS.SharedEventEmitter.removeListener.bind(INTERNALS.SharedEventEmitter);
}
get removeAllListeners() {
get removeAllListeners(): Function {
return INTERNALS.SharedEventEmitter.removeAllListeners.bind(INTERNALS.SharedEventEmitter);
}
}