@cripty2001/utils 0.0.194 → 0.0.195
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/dist/Appstorage.d.ts +2 -0
- package/dist/Appstorage.js +12 -4
- package/package.json +1 -1
package/dist/Appstorage.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface IAppstorageItem<T extends AppstorageData> {
|
|
|
13
13
|
readonly data: Whispr<AppstorageItemData<T>>;
|
|
14
14
|
readonly update: (data: T) => void;
|
|
15
15
|
readonly remove: () => void;
|
|
16
|
+
readonly flush: () => void;
|
|
16
17
|
}
|
|
17
18
|
export declare class Appstorage {
|
|
18
19
|
private static readonly instances;
|
|
@@ -26,4 +27,5 @@ export declare class Appstorage {
|
|
|
26
27
|
get<T extends AppstorageData>(key: string): IAppstorageItem<T>;
|
|
27
28
|
private listData;
|
|
28
29
|
private refresh;
|
|
30
|
+
flush(): void;
|
|
29
31
|
}
|
package/dist/Appstorage.js
CHANGED
|
@@ -70,6 +70,11 @@ class Appstorage {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
flush() {
|
|
74
|
+
Object.values(this.index.value).forEach(item => {
|
|
75
|
+
item.flush();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
exports.Appstorage = Appstorage;
|
|
75
80
|
class AppstorageItem {
|
|
@@ -114,12 +119,15 @@ class AppstorageItem {
|
|
|
114
119
|
});
|
|
115
120
|
};
|
|
116
121
|
new Dispatcher_1.Dispatcher(this.data, async () => {
|
|
117
|
-
|
|
118
|
-
if (this.data.value.rev > curr.rev) {
|
|
119
|
-
localStorage.setItem(`${this.PREFIX}${this.key}`, JSON.stringify(this.data.value));
|
|
120
|
-
}
|
|
122
|
+
this.flush();
|
|
121
123
|
}, 500);
|
|
122
124
|
}
|
|
125
|
+
flush() {
|
|
126
|
+
const curr = this.loadData();
|
|
127
|
+
if (this.data.value.rev > curr.rev) {
|
|
128
|
+
localStorage.setItem(`${this.PREFIX}${this.key}`, JSON.stringify(this.data.value));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
123
131
|
refresh() {
|
|
124
132
|
const data = this.loadData();
|
|
125
133
|
if (data.rev > this.data.value.rev) {
|
package/package.json
CHANGED