zova-module-a-model 5.0.10 → 5.0.11
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-model",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.11",
|
|
4
4
|
"title": "a-model",
|
|
5
5
|
"zovaModule": {
|
|
6
6
|
"capabilities": {
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"js-cookie": "^3.0.5",
|
|
64
64
|
"localforage": "^1.10.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "d7ecefeb8b5f566e4b4831d7b3a02e9e7a765c15"
|
|
67
67
|
}
|
|
@@ -66,23 +66,13 @@ export class BeanModelUseQuery<TScopeModule = unknown> extends BeanModelQuery<TS
|
|
|
66
66
|
persister: { storage: 'local', sync: true },
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
|
-
const queryKey = options.queryKey;
|
|
70
69
|
const self = this;
|
|
71
70
|
return useComputed({
|
|
72
71
|
get() {
|
|
73
|
-
|
|
74
|
-
if (query.data === undefined) {
|
|
75
|
-
const data = self.$persisterLoad(queryKey);
|
|
76
|
-
if (data !== undefined) {
|
|
77
|
-
self.$setQueryData(queryKey, data);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return query.data;
|
|
72
|
+
return self._handleSyncDataGet(options, queryClient, true);
|
|
81
73
|
},
|
|
82
74
|
set(value) {
|
|
83
|
-
|
|
84
|
-
self.$setQueryData(queryKey, value, true);
|
|
85
|
-
return query;
|
|
75
|
+
self._handleSyncDataSet(options, queryClient, true, value);
|
|
86
76
|
},
|
|
87
77
|
});
|
|
88
78
|
}
|
|
@@ -128,23 +118,13 @@ export class BeanModelUseQuery<TScopeModule = unknown> extends BeanModelQuery<TS
|
|
|
128
118
|
},
|
|
129
119
|
},
|
|
130
120
|
);
|
|
131
|
-
const queryKey = options.queryKey;
|
|
132
121
|
const self = this;
|
|
133
122
|
return useComputed({
|
|
134
123
|
get() {
|
|
135
|
-
|
|
136
|
-
if (query.data === undefined) {
|
|
137
|
-
const data = self.$persisterLoad(queryKey);
|
|
138
|
-
if (data !== undefined) {
|
|
139
|
-
self.$setQueryData(queryKey, data);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return query.data;
|
|
124
|
+
return self._handleSyncDataGet(options, queryClient, true);
|
|
143
125
|
},
|
|
144
126
|
set(value) {
|
|
145
|
-
|
|
146
|
-
self.$setQueryData(queryKey, value, true);
|
|
147
|
-
return query;
|
|
127
|
+
self._handleSyncDataSet(options, queryClient, true, value);
|
|
148
128
|
},
|
|
149
129
|
});
|
|
150
130
|
}
|
|
@@ -175,17 +155,13 @@ export class BeanModelUseQuery<TScopeModule = unknown> extends BeanModelQuery<TS
|
|
|
175
155
|
persister: false,
|
|
176
156
|
},
|
|
177
157
|
});
|
|
178
|
-
const queryKey = options.queryKey;
|
|
179
158
|
const self = this;
|
|
180
159
|
return useComputed({
|
|
181
160
|
get() {
|
|
182
|
-
|
|
183
|
-
return query.data;
|
|
161
|
+
return self._handleSyncDataGet(options, queryClient, false);
|
|
184
162
|
},
|
|
185
163
|
set(value) {
|
|
186
|
-
|
|
187
|
-
self.$setQueryData(queryKey, value, false);
|
|
188
|
-
return query;
|
|
164
|
+
self._handleSyncDataSet(options, queryClient, false, value);
|
|
189
165
|
},
|
|
190
166
|
});
|
|
191
167
|
}
|
|
@@ -225,4 +201,35 @@ export class BeanModelUseQuery<TScopeModule = unknown> extends BeanModelQuery<TS
|
|
|
225
201
|
}
|
|
226
202
|
return this[SymbolUseQueries][queryHash];
|
|
227
203
|
}
|
|
204
|
+
|
|
205
|
+
private _handleSyncDataGet(options, queryClient, persister) {
|
|
206
|
+
const queryKey = options.queryKey;
|
|
207
|
+
const query = this.$useQueryExisting(options, queryClient);
|
|
208
|
+
if (query.data === undefined) {
|
|
209
|
+
if (persister) {
|
|
210
|
+
const data = this.$persisterLoad(queryKey);
|
|
211
|
+
if (data !== undefined) {
|
|
212
|
+
this.$setQueryData(queryKey, data, false);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (query.data === undefined) {
|
|
216
|
+
let defaultData = options.meta?.defaultData;
|
|
217
|
+
if (typeof defaultData === 'function') {
|
|
218
|
+
defaultData = defaultData();
|
|
219
|
+
}
|
|
220
|
+
if (defaultData !== undefined) {
|
|
221
|
+
// need not persister save
|
|
222
|
+
this.$setQueryData(queryKey, defaultData, false);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return query.data;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private _handleSyncDataSet(options, queryClient, persister, value) {
|
|
230
|
+
const queryKey = options.queryKey;
|
|
231
|
+
const query = this.$useQueryExisting(options, queryClient);
|
|
232
|
+
this.$setQueryData(queryKey, value, persister);
|
|
233
|
+
return query;
|
|
234
|
+
}
|
|
228
235
|
}
|