Firebase Stub: added support for data remove

This commit is contained in:
gianantoniopini
2021-01-14 17:16:01 +01:00
parent 46781bba60
commit 6ac0f37ada
4 changed files with 109 additions and 43 deletions
@@ -1,16 +1,6 @@
/* eslint-disable no-underscore-dangle */
import DatabaseConstants from '../constants/database';
class DataSnapshot {
constructor(eventType, getData, value = undefined) {
if (!eventType) {
throw new Error('eventType must be provided.');
} else if (typeof eventType !== 'string') {
throw new Error('eventType should be a string.');
}
this._eventType = eventType;
constructor(getData, value = undefined) {
if (!getData) {
throw new Error('getData must be provided.');
} else if (typeof getData !== 'function') {
@@ -22,20 +12,12 @@ class DataSnapshot {
this._value = value;
}
get eventType() {
return this._eventType;
}
get value() {
return this._value;
}
val() {
if (this.eventType === DatabaseConstants.valueEventType) {
return typeof this.value !== 'undefined' ? this.value : this._getData();
}
return undefined;
return typeof this.value !== 'undefined' ? this.value : this._getData();
}
}