mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-27 18:34:51 +10:00
Firebase Stub: added support for data remove
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user