@nativescript/firebase-firestore
Version:
NativeScript Firebase - Firestore
38 lines • 1.44 kB
JavaScript
export var GetOptions;
(function (GetOptions) {
GetOptions["Default"] = "default";
GetOptions["Server"] = "server";
GetOptions["Cache"] = "cache";
})(GetOptions || (GetOptions = {}));
export var DocumentChangeType;
(function (DocumentChangeType) {
DocumentChangeType["Added"] = "added";
DocumentChangeType["Removed"] = "removed";
DocumentChangeType["Modified"] = "modified";
})(DocumentChangeType || (DocumentChangeType = {}));
export function parseOnSnapshotArgs(args) {
const result = {
includeMetadataChanges: false
};
for (let i = 0; i < args.length; ++i) {
if (args[i] instanceof Function) {
// Assign whichever of next, error, complete were passed starting here
const fnArgsMappingOrder = ['next', 'error', 'complete'];
args.slice(i).forEach((fn, idx) => result[fnArgsMappingOrder[idx]] = fn);
break;
}
else if (typeof args[i] === 'object') {
if ('includeMetadataChanges' in args[i]) {
result.includeMetadataChanges = Boolean(args[i].includeMetadataChanges);
}
else { // Must be Observer
Object.assign(result, args[i]);
}
}
else {
throw new Error(`Invalid argument to onSnapshot at position ${i} of type ${typeof args[i]}: ${args[i]}`);
}
}
return result;
}
//# sourceMappingURL=common.js.map