@astral/mobx-query 1.12.0 → 1.12.2
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/MobxQuery/MobxQuery.js +2 -2
- package/README.md +14 -0
- package/node/MobxQuery/MobxQuery.js +2 -2
- package/package.json +1 -1
package/MobxQuery/MobxQuery.js
CHANGED
|
@@ -144,10 +144,10 @@ export class MobxQuery {
|
|
|
144
144
|
const queryKey = [...rootKey, { fetchPolicy, date, isBackground, type }];
|
|
145
145
|
const queryKeyHash = this.serialize(queryKey);
|
|
146
146
|
const dataKeyHash = this.serialize([...rootKey, { type }]);
|
|
147
|
-
const statusKeyHash = this.serialize([...rootKey, { type }]);
|
|
147
|
+
const statusKeyHash = this.serialize([...rootKey, { type, date }]);
|
|
148
148
|
const backgroundStatusKeyHash = this.serialize([
|
|
149
149
|
...rootKey,
|
|
150
|
-
{ type, isBackground },
|
|
150
|
+
{ type, isBackground, date },
|
|
151
151
|
]);
|
|
152
152
|
return {
|
|
153
153
|
queryKey,
|
package/README.md
CHANGED
|
@@ -648,6 +648,20 @@ const docQuery = docsFetcher.queries.doc.create('docID');
|
|
|
648
648
|
docQuery.forceUpdate({ name: 'test' });
|
|
649
649
|
```
|
|
650
650
|
|
|
651
|
+
Для массового изменения требуется использовать метод `forceUpdate` предоставляемый `QuerySet` или `InfiniteQuerySet`.
|
|
652
|
+
Первым аргументом является метод для анализа, и изменения данных. Начиная со второго, аргументы идентичны тем, что вы используете при созданнии и инвалидации.
|
|
653
|
+
|
|
654
|
+
```ts
|
|
655
|
+
const queryA = docsFetcher.queries.docsList.create(userId);
|
|
656
|
+
const queryB = docsFetcher.queries.docsList.create(userId, { isDesc: true });
|
|
657
|
+
|
|
658
|
+
docsFetcher.queries.docsList.forceUpdate(
|
|
659
|
+
(currentData = []) => [...currentData, 'дополнительный элемент'], userId
|
|
660
|
+
);
|
|
661
|
+
console.log(queryA.data); // ['дополнительный элемент']
|
|
662
|
+
console.log(queryB.data); // ['дополнительный элемент']
|
|
663
|
+
```
|
|
664
|
+
|
|
651
665
|
## Тестирование Fetcher на сонове QuerySet и InfiniteQuerySet.
|
|
652
666
|
|
|
653
667
|
Для мокинга QuerySet и InfiniteQuerySet необходимо использовать mock следующего вида:
|
|
@@ -147,10 +147,10 @@ class MobxQuery {
|
|
|
147
147
|
const queryKey = [...rootKey, { fetchPolicy, date, isBackground, type }];
|
|
148
148
|
const queryKeyHash = this.serialize(queryKey);
|
|
149
149
|
const dataKeyHash = this.serialize([...rootKey, { type }]);
|
|
150
|
-
const statusKeyHash = this.serialize([...rootKey, { type }]);
|
|
150
|
+
const statusKeyHash = this.serialize([...rootKey, { type, date }]);
|
|
151
151
|
const backgroundStatusKeyHash = this.serialize([
|
|
152
152
|
...rootKey,
|
|
153
|
-
{ type, isBackground },
|
|
153
|
+
{ type, isBackground, date },
|
|
154
154
|
]);
|
|
155
155
|
return {
|
|
156
156
|
queryKey,
|