[js] Run prettier for the first time

This commit is contained in:
Chris Bianca
2018-01-25 18:25:39 +00:00
parent 8feffd85c5
commit fba6380729
124 changed files with 4343 additions and 2633 deletions

View File

@@ -8,7 +8,7 @@ import DatabaseSnapshot from '../modules/database/snapshot';
import DatabaseReference from '../modules/database/reference';
import { isString, nativeToJSError } from '../utils';
type Listener = (DatabaseSnapshot) => any;
type Listener = DatabaseSnapshot => any;
type Registration = {
key: string,
@@ -19,7 +19,7 @@ type Registration = {
listener: Listener,
eventRegistrationKey: string,
ref: DatabaseReference,
}
};
/**
* Internally used to manage firebase database realtime event
@@ -28,16 +28,18 @@ type Registration = {
class SyncTree {
_nativeEmitter: NativeEventEmitter;
_reverseLookup: { [string]: Registration };
_tree: { [string]: { [string]: { [string]: Listener }}};
_tree: { [string]: { [string]: { [string]: Listener } } };
constructor() {
this._tree = {};
this._reverseLookup = {};
if (NativeModules.RNFirebaseDatabase) {
this._nativeEmitter = new NativeEventEmitter(NativeModules.RNFirebaseDatabase);
this._nativeEmitter = new NativeEventEmitter(
NativeModules.RNFirebaseDatabase
);
this._nativeEmitter.addListener(
'database_sync_event',
this._handleSyncEvent.bind(this),
this._handleSyncEvent.bind(this)
);
}
}
@@ -82,11 +84,10 @@ class SyncTree {
return SharedEventEmitter.emit(
eventRegistrationKey,
new DatabaseSnapshot(registration.ref, snapshot),
previousChildName,
previousChildName
);
}
/**
* Routes native database query listener cancellation events to their js counterparts.
*
@@ -96,7 +97,10 @@ class SyncTree {
_handleErrorEvent(event) {
// console.log('SyncTree.ERROR >>>', event);
const { code, message } = event.error;
const { eventRegistrationKey, registrationCancellationKey } = event.registration;
const {
eventRegistrationKey,
registrationCancellationKey,
} = event.registration;
const registration = this.getRegistration(registrationCancellationKey);
@@ -121,7 +125,9 @@ class SyncTree {
* @return {null}
*/
getRegistration(registration: string): Registration | null {
return this._reverseLookup[registration] ? Object.assign({}, this._reverseLookup[registration]) : null;
return this._reverseLookup[registration]
? Object.assign({}, this._reverseLookup[registration])
: null;
}
/**
@@ -159,7 +165,9 @@ class SyncTree {
for (let i = 0, len = registrations.length; i < len; i++) {
const registration = registrations[i];
const subscriptions = SharedEventEmitter._subscriber.getSubscriptionsForType(registration);
const subscriptions = SharedEventEmitter._subscriber.getSubscriptionsForType(
registration
);
if (subscriptions) {
for (let j = 0, l = subscriptions.length; j < l; j++) {
const subscription = subscriptions[j];
@@ -188,7 +196,10 @@ class SyncTree {
const eventKeys = Object.keys(this._tree[path] || {});
for (let i = 0, len = eventKeys.length; i < len; i++) {
Array.prototype.push.apply(out, Object.keys(this._tree[path][eventKeys[i]]));
Array.prototype.push.apply(
out,
Object.keys(this._tree[path][eventKeys[i]])
);
}
return out;
@@ -216,11 +227,17 @@ class SyncTree {
* @param listener
* @return {Array}
*/
getOneByPathEventListener(path: string, eventType: string, listener: Function): ?string {
getOneByPathEventListener(
path: string,
eventType: string,
listener: Function
): ?string {
if (!this._tree[path]) return null;
if (!this._tree[path][eventType]) return null;
const registrationsForPathEvent = Object.entries(this._tree[path][eventType]);
const registrationsForPathEvent = Object.entries(
this._tree[path][eventType]
);
for (let i = 0; i < registrationsForPathEvent.length; i++) {
const registration = registrationsForPathEvent[i];
@@ -230,7 +247,6 @@ class SyncTree {
return null;
}
/**
* Register a new listener.
*
@@ -256,7 +272,7 @@ class SyncTree {
if (once) {
SharedEventEmitter.once(
eventRegistrationKey,
this._onOnceRemoveRegistration(eventRegistrationKey, listener),
this._onOnceRemoveRegistration(eventRegistrationKey, listener)
);
} else {
SharedEventEmitter.addListener(eventRegistrationKey, listener);