sliftutils 0.65.0 → 0.66.0
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.
package/index.d.ts
CHANGED
|
@@ -938,9 +938,6 @@ declare module "sliftutils/storage/StorageObservable" {
|
|
|
938
938
|
synced: {
|
|
939
939
|
keySeqNum: number;
|
|
940
940
|
};
|
|
941
|
-
resynced: {
|
|
942
|
-
seqNum: number;
|
|
943
|
-
};
|
|
944
941
|
constructor(storage: IStorage<T>);
|
|
945
942
|
get(key: string): T | undefined;
|
|
946
943
|
set(key: string, value: T): void;
|
package/package.json
CHANGED
|
@@ -11,16 +11,17 @@ export class StorageSync<T> implements IStorageSync<T> {
|
|
|
11
11
|
keySeqNum: 0,
|
|
12
12
|
}, undefined, { deep: false });
|
|
13
13
|
|
|
14
|
-
resynced = observable({ seqNum: 0 });
|
|
15
|
-
|
|
16
14
|
constructor(public storage: IStorage<T>) {
|
|
17
15
|
storage.watchResync?.(() => {
|
|
18
|
-
this.
|
|
16
|
+
this.cached.clear();
|
|
17
|
+
this.infoCached.clear();
|
|
18
|
+
this.keys.clear();
|
|
19
|
+
this.loadedKeys = false;
|
|
20
|
+
this.synced.keySeqNum++;
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
public get(key: string): T | undefined {
|
|
23
|
-
this.resynced.seqNum;
|
|
24
25
|
if (!this.cached.has(key)) {
|
|
25
26
|
this.cached.set(key, undefined);
|
|
26
27
|
void this.getPromise(key);
|
|
@@ -48,14 +49,12 @@ export class StorageSync<T> implements IStorageSync<T> {
|
|
|
48
49
|
}
|
|
49
50
|
private loadedKeys = false;
|
|
50
51
|
public getKeys(): string[] {
|
|
51
|
-
this.resynced.seqNum;
|
|
52
52
|
void this.getKeysPromise();
|
|
53
53
|
this.synced.keySeqNum;
|
|
54
54
|
return Array.from(this.keys);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
public getInfo(key: string): { size: number; lastModified: number } | undefined {
|
|
58
|
-
this.resynced.seqNum;
|
|
59
58
|
if (!this.infoCached.has(key)) {
|
|
60
59
|
this.infoCached.set(key, { size: 0, lastModified: 0 });
|
|
61
60
|
void this.storage.getInfo(key).then(info => {
|