mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 00:32:35 +10:00
Firebase Stub: resolving ESLint errors
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
import Reference from './reference';
|
||||
|
||||
class DataSnapshot {
|
||||
constructor(eventType, reference, value = undefined) {
|
||||
constructor(eventType, getDataCallback, value = undefined) {
|
||||
if (!eventType) {
|
||||
throw new Error('eventType must be provided.');
|
||||
} else if (typeof eventType !== 'string') {
|
||||
@ -10,13 +8,13 @@ class DataSnapshot {
|
||||
|
||||
this.eventTypeField = eventType;
|
||||
|
||||
if (!reference) {
|
||||
throw new Error('reference must be provided.');
|
||||
} else if (!(reference instanceof Reference)) {
|
||||
throw new Error('reference must be an instance of the Reference class.');
|
||||
if (!getDataCallback) {
|
||||
throw new Error('getDataCallback must be provided.');
|
||||
} else if (typeof getDataCallback !== 'function') {
|
||||
throw new Error('getDataCallback should be a function.');
|
||||
}
|
||||
|
||||
this.referenceField = reference;
|
||||
this.getDataCallbackField = getDataCallback;
|
||||
|
||||
this.valueField = value;
|
||||
}
|
||||
@ -33,7 +31,7 @@ class DataSnapshot {
|
||||
if (this.eventType === 'value') {
|
||||
return typeof this.value !== 'undefined'
|
||||
? this.value
|
||||
: this.referenceField.getData();
|
||||
: this.getDataCallbackField();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@ -6,7 +6,7 @@ import DataSnapshot from './dataSnapshot';
|
||||
const rootPath = '.';
|
||||
|
||||
class Reference {
|
||||
constructor(path, getDatabaseData) {
|
||||
constructor(path, getDatabaseDataCallback) {
|
||||
if (typeof path === 'undefined' || path === null) {
|
||||
this.pathField = rootPath;
|
||||
} else if (typeof path !== 'string') {
|
||||
@ -16,15 +16,16 @@ class Reference {
|
||||
}
|
||||
|
||||
this.uuidField = uuidv4();
|
||||
|
||||
this.dataSnapshotsField = {};
|
||||
|
||||
if (!getDatabaseData) {
|
||||
throw new Error('getDatabaseData must be provided.');
|
||||
} else if (typeof getDatabaseData !== 'function') {
|
||||
throw new Error('getDatabaseData should be a function.');
|
||||
if (!getDatabaseDataCallback) {
|
||||
throw new Error('getDatabaseDataCallback must be provided.');
|
||||
} else if (typeof getDatabaseDataCallback !== 'function') {
|
||||
throw new Error('getDatabaseDataCallback should be a function.');
|
||||
}
|
||||
|
||||
this.getDatabaseDataField = getDatabaseData;
|
||||
this.getDatabaseDataCallbackField = getDatabaseDataCallback;
|
||||
|
||||
this.orderByChildPathField = '';
|
||||
this.equalToValueField = '';
|
||||
@ -39,7 +40,7 @@ class Reference {
|
||||
}
|
||||
|
||||
getData() {
|
||||
const databaseData = this.getDatabaseDataField();
|
||||
const databaseData = this.getDatabaseDataCallbackField();
|
||||
|
||||
if (!databaseData) {
|
||||
return null;
|
||||
@ -99,19 +100,19 @@ class Reference {
|
||||
return;
|
||||
}
|
||||
|
||||
let snapshot = new DataSnapshot(eventType, this, null);
|
||||
let snapshot = new DataSnapshot(eventType, () => this.getData(), null);
|
||||
|
||||
if (this.path === DatabaseConstants.connectedPath) {
|
||||
snapshot = new DataSnapshot(eventType, this, true);
|
||||
snapshot = new DataSnapshot(eventType, () => this.getData(), true);
|
||||
} else if (this.path === DatabaseConstants.resumesPath) {
|
||||
snapshot = new DataSnapshot(eventType, this);
|
||||
snapshot = new DataSnapshot(eventType, () => this.getData());
|
||||
}
|
||||
|
||||
callback(snapshot);
|
||||
}
|
||||
|
||||
async once(eventType) {
|
||||
const newDataSnapshot = new DataSnapshot(eventType, this);
|
||||
const newDataSnapshot = new DataSnapshot(eventType, () => this.getData());
|
||||
const existingDataSnapshot = this.dataSnapshotsField[
|
||||
newDataSnapshot.eventType
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user