@astral/mobx-query 1.16.1 → 1.16.3
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/InfiniteQuery/InfiniteQuery.d.ts +1 -0
- package/InfiniteQuery/InfiniteQuery.js +6 -2
- package/PollingService/PollingService.js +2 -2
- package/node/InfiniteQuery/InfiniteQuery.d.ts +1 -0
- package/node/InfiniteQuery/InfiniteQuery.js +6 -2
- package/node/PollingService/PollingService.js +2 -2
- package/package.json +1 -1
|
@@ -131,6 +131,7 @@ export declare class InfiniteQuery<TResult, TError = void, TIsBackground extends
|
|
|
131
131
|
* предполагается, что нужно будет самостоятельно обрабатывать ошибку
|
|
132
132
|
*/
|
|
133
133
|
async: () => Promise<TResult[]>;
|
|
134
|
+
private get computedData();
|
|
134
135
|
/**
|
|
135
136
|
* Вычисляемое свойство, содержащее реактивные данные,
|
|
136
137
|
* благодаря mobx, при изменении isInvalid, свойство будет вычисляться заново,
|
|
@@ -144,6 +144,7 @@ export class InfiniteQuery extends QueryContainer {
|
|
|
144
144
|
this.submitValidity = submitValidity;
|
|
145
145
|
makeObservable(this, {
|
|
146
146
|
data: computed,
|
|
147
|
+
computedData: computed,
|
|
147
148
|
infiniteExecutor: computed,
|
|
148
149
|
forceUpdate: action,
|
|
149
150
|
async: action,
|
|
@@ -179,6 +180,10 @@ export class InfiniteQuery extends QueryContainer {
|
|
|
179
180
|
count: this.incrementCount,
|
|
180
181
|
});
|
|
181
182
|
}
|
|
183
|
+
get computedData() {
|
|
184
|
+
var _a;
|
|
185
|
+
return (_a = this.storage.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
186
|
+
}
|
|
182
187
|
/**
|
|
183
188
|
* Вычисляемое свойство, содержащее реактивные данные,
|
|
184
189
|
* благодаря mobx, при изменении isInvalid, свойство будет вычисляться заново,
|
|
@@ -186,7 +191,6 @@ export class InfiniteQuery extends QueryContainer {
|
|
|
186
191
|
* и начнется запрос, в результате которого, данные обновятся
|
|
187
192
|
*/
|
|
188
193
|
get data() {
|
|
189
|
-
var _a;
|
|
190
194
|
const shouldSync = this.enabledAutoFetch &&
|
|
191
195
|
!this.isSuccess &&
|
|
192
196
|
!this.isLoading &&
|
|
@@ -197,6 +201,6 @@ export class InfiniteQuery extends QueryContainer {
|
|
|
197
201
|
when(() => true, this.proceedSync);
|
|
198
202
|
}
|
|
199
203
|
// возвращаем имеющиеся данные
|
|
200
|
-
return
|
|
204
|
+
return this.computedData;
|
|
201
205
|
}
|
|
202
206
|
}
|
|
@@ -28,7 +28,7 @@ export class PollingService {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
this.restartPausedTimers = () => {
|
|
31
|
-
this.timerDates.keys().forEach((key) => {
|
|
31
|
+
[...this.timerDates.keys()].forEach((key) => {
|
|
32
32
|
const dateNow = Date.now();
|
|
33
33
|
const { pollingTime, targetDate } = this.timerDates.get(key);
|
|
34
34
|
const isAlreadyExpired = targetDate < dateNow;
|
|
@@ -41,7 +41,7 @@ export class PollingService {
|
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
this.pauseTimers = () => {
|
|
44
|
-
this.timers.keys().forEach((key) => {
|
|
44
|
+
[...this.timers.keys()].forEach((key) => {
|
|
45
45
|
globalThis.clearTimeout(this.timers.get(key));
|
|
46
46
|
this.timers.delete(key);
|
|
47
47
|
});
|
|
@@ -131,6 +131,7 @@ export declare class InfiniteQuery<TResult, TError = void, TIsBackground extends
|
|
|
131
131
|
* предполагается, что нужно будет самостоятельно обрабатывать ошибку
|
|
132
132
|
*/
|
|
133
133
|
async: () => Promise<TResult[]>;
|
|
134
|
+
private get computedData();
|
|
134
135
|
/**
|
|
135
136
|
* Вычисляемое свойство, содержащее реактивные данные,
|
|
136
137
|
* благодаря mobx, при изменении isInvalid, свойство будет вычисляться заново,
|
|
@@ -147,6 +147,7 @@ class InfiniteQuery extends QueryContainer_1.QueryContainer {
|
|
|
147
147
|
this.submitValidity = submitValidity;
|
|
148
148
|
(0, mobx_1.makeObservable)(this, {
|
|
149
149
|
data: mobx_1.computed,
|
|
150
|
+
computedData: mobx_1.computed,
|
|
150
151
|
infiniteExecutor: mobx_1.computed,
|
|
151
152
|
forceUpdate: mobx_1.action,
|
|
152
153
|
async: mobx_1.action,
|
|
@@ -182,6 +183,10 @@ class InfiniteQuery extends QueryContainer_1.QueryContainer {
|
|
|
182
183
|
count: this.incrementCount,
|
|
183
184
|
});
|
|
184
185
|
}
|
|
186
|
+
get computedData() {
|
|
187
|
+
var _a;
|
|
188
|
+
return (_a = this.storage.data) === null || _a === void 0 ? void 0 : _a.data;
|
|
189
|
+
}
|
|
185
190
|
/**
|
|
186
191
|
* Вычисляемое свойство, содержащее реактивные данные,
|
|
187
192
|
* благодаря mobx, при изменении isInvalid, свойство будет вычисляться заново,
|
|
@@ -189,7 +194,6 @@ class InfiniteQuery extends QueryContainer_1.QueryContainer {
|
|
|
189
194
|
* и начнется запрос, в результате которого, данные обновятся
|
|
190
195
|
*/
|
|
191
196
|
get data() {
|
|
192
|
-
var _a;
|
|
193
197
|
const shouldSync = this.enabledAutoFetch &&
|
|
194
198
|
!this.isSuccess &&
|
|
195
199
|
!this.isLoading &&
|
|
@@ -200,7 +204,7 @@ class InfiniteQuery extends QueryContainer_1.QueryContainer {
|
|
|
200
204
|
(0, mobx_1.when)(() => true, this.proceedSync);
|
|
201
205
|
}
|
|
202
206
|
// возвращаем имеющиеся данные
|
|
203
|
-
return
|
|
207
|
+
return this.computedData;
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
exports.InfiniteQuery = InfiniteQuery;
|
|
@@ -31,7 +31,7 @@ class PollingService {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
this.restartPausedTimers = () => {
|
|
34
|
-
this.timerDates.keys().forEach((key) => {
|
|
34
|
+
[...this.timerDates.keys()].forEach((key) => {
|
|
35
35
|
const dateNow = Date.now();
|
|
36
36
|
const { pollingTime, targetDate } = this.timerDates.get(key);
|
|
37
37
|
const isAlreadyExpired = targetDate < dateNow;
|
|
@@ -44,7 +44,7 @@ class PollingService {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
this.pauseTimers = () => {
|
|
47
|
-
this.timers.keys().forEach((key) => {
|
|
47
|
+
[...this.timers.keys()].forEach((key) => {
|
|
48
48
|
globalThis.clearTimeout(this.timers.get(key));
|
|
49
49
|
this.timers.delete(key);
|
|
50
50
|
});
|