@data-weave/backend-firestore 0.4.24 → 0.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,7 @@ export interface FirebaseDataManagerOptions {
|
|
|
15
15
|
readonly List?: typeof FirestoreList;
|
|
16
16
|
readonly listCache?: Cache;
|
|
17
17
|
readonly refCache?: Cache;
|
|
18
|
+
readonly disableCache?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export interface QueryParams<T> {
|
|
20
21
|
readonly filters?: Array<FilterBy<T & FirestoreSerializedMetadata>>;
|
|
@@ -165,7 +165,7 @@ let FirestoreDataManager = (() => {
|
|
|
165
165
|
var _a;
|
|
166
166
|
if (!((_a = this.managerOptions) === null || _a === void 0 ? void 0 : _a.Reference))
|
|
167
167
|
throw new Error('ReferenceClass not defined');
|
|
168
|
-
if (this.refCache.has(id)) {
|
|
168
|
+
if (this.refCache.has(id) && !this.managerOptions.disableCache) {
|
|
169
169
|
return this.refCache.get(id);
|
|
170
170
|
}
|
|
171
171
|
const newRef = new this.managerOptions.Reference(this.firestore, this.firestore.doc(this.collection, id), {
|
|
@@ -173,7 +173,9 @@ let FirestoreDataManager = (() => {
|
|
|
173
173
|
errorInterceptor: this.managerOptions.errorInterceptor,
|
|
174
174
|
snapshotOptions: this.managerOptions.snapshotOptions,
|
|
175
175
|
});
|
|
176
|
-
this.
|
|
176
|
+
if (!this.managerOptions.disableCache) {
|
|
177
|
+
this.refCache.set(id, newRef);
|
|
178
|
+
}
|
|
177
179
|
return newRef;
|
|
178
180
|
}
|
|
179
181
|
_getFilteredQuery(params) {
|
|
@@ -192,11 +194,13 @@ let FirestoreDataManager = (() => {
|
|
|
192
194
|
throw new Error('ListClass not defined');
|
|
193
195
|
const compoundQuery = this._getFilteredQuery(params);
|
|
194
196
|
const key = JSON.stringify(params || {});
|
|
195
|
-
if (this.listCache.has(key)) {
|
|
197
|
+
if (this.listCache.has(key) && !this.managerOptions.disableCache) {
|
|
196
198
|
return this.listCache.get(key);
|
|
197
199
|
}
|
|
198
200
|
const newList = new this.managerOptions.List(this.firestore, compoundQuery, Object.assign({ readMode: this.managerOptions.readMode, errorInterceptor: this.managerOptions.errorInterceptor }, params));
|
|
199
|
-
this.
|
|
201
|
+
if (!this.managerOptions.disableCache) {
|
|
202
|
+
this.listCache.set(key, newList);
|
|
203
|
+
}
|
|
200
204
|
return newList;
|
|
201
205
|
}
|
|
202
206
|
preventOverwriteOnCreate(docRef, createOptions) {
|
package/lib/FirestoreList.js
CHANGED
|
@@ -59,6 +59,7 @@ class FirestoreList extends datamanager_1.LiveList {
|
|
|
59
59
|
this.onUpdateAll(newValues);
|
|
60
60
|
}
|
|
61
61
|
handleSubsequentDataChanges(changes) {
|
|
62
|
+
const newValues = [...this.values];
|
|
62
63
|
changes.forEach(change => {
|
|
63
64
|
if (change.type === 'added') {
|
|
64
65
|
this.onAddAtIndex(change.newIndex, change.doc.data());
|
|
@@ -70,8 +71,9 @@ class FirestoreList extends datamanager_1.LiveList {
|
|
|
70
71
|
this.onRemoveAtIndex(change.oldIndex);
|
|
71
72
|
}
|
|
72
73
|
});
|
|
74
|
+
this.onUpdateAll(newValues);
|
|
73
75
|
// TODO: handle onUpdate in the parent class - make sure it's only called once after all changes are processed
|
|
74
|
-
this.onUpdate()
|
|
76
|
+
// this.onUpdate()
|
|
75
77
|
}
|
|
76
78
|
unSubscribe() {
|
|
77
79
|
var _a;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-weave/backend-firestore",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.26",
|
|
4
4
|
"author": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"registry": "https://registry.npmjs.org/"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@data-weave/datamanager": "~0.4.
|
|
26
|
+
"@data-weave/datamanager": "~0.4.25",
|
|
27
27
|
"firebase": ">=11.0.0"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "70c0827db3b7982a46ae896d1693b02a6581bc4d"
|
|
30
30
|
}
|