You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,23 @@
1
1
# mobx-tanstack-query
2
2
3
+
## 6.16.0
4
+
5
+
### Minor Changes
6
+
7
+
-[`da6909d`](https://github.com/js2me/mobx-tanstack-query/commit/da6909daed63441f63e8240eea32c31b37c7f668) Thanks [@js2me](https://github.com/js2me)! - added `lazyDelay` option for queries and mutations as features
8
+
9
+
## 6.15.1
10
+
11
+
### Patch Changes
12
+
13
+
-[`eeb0abf`](https://github.com/js2me/mobx-tanstack-query/commit/eeb0abf73cbbe75551d94eb164cc25b0b12a75a5) Thanks [@js2me](https://github.com/js2me)! - fixed `resultObservable` work with merging with query client
14
+
15
+
## 6.15.0
16
+
17
+
### Minor Changes
18
+
19
+
-[`73207cc`](https://github.com/js2me/mobx-tanstack-query/commit/73207cc8e22303d0a2975bac12eedcd4c14945a0) Thanks [@js2me](https://github.com/js2me)! - added `resultObservable` query and mutation features
[_Can be specified using `QueryClient`_](https://js2me.github.io/mobx-tanstack-query/api/QueryClient.html#mutationfeatures)
158
+
159
+
Only applies when [`lazy`](#lazy-option) is enabled.
160
+
161
+
After the last MobX observer stops reading the mutation **`result`**, the library keeps the `MutationObserver` subscription alive for an extra **`lazyDelay` milliseconds** before tearing it down. This uses the `endDelay` option of [`lazyObserve`](https://www.npmjs.com/package/yummies) from `yummies/mobx`, same as for [`Query``lazyDelay`](https://js2me.github.io/mobx-tanstack-query/api/Query.html#lazydelay-option-queryfeature).
162
+
163
+
Use it to smooth over short-lived UI changes so you do not drop the observer subscription on every transient unmount.
164
+
165
+
When **`lazyDelay`** is omitted, teardown follows the same rules as for [`Query``lazyDelay`](https://js2me.github.io/mobx-tanstack-query/api/Query.html#lazydelay-option-queryfeature) (no extra delay unless you set a number).
[_Can be specified using `QueryClient`_](https://js2me.github.io/mobx-tanstack-query/api/QueryClient.html#mutationfeatures)
179
+
180
+
Chooses how MobX observes the mutation **`result`** property (the `MutationObserverResult`). The library applies `annotation.observable()` from [`yummies/mobx`](https://github.com/js2me/yummies). [`Query`](https://js2me.github.io/mobx-tanstack-query/api/Query.html#resultobservable-queryfeature) stores the payload on a private `_result` and exposes TanStack fields via getters; **`Mutation` decorates the public `result` field directly** — there is no `_result`.
181
+
182
+
-**Default** — when omitted, behaviour matches **`'deep'`** (deep observability for plain objects and arrays in the result).
183
+
-**`'ref'`** — only the reference to the result object is tracked; reactions run when the whole result is replaced, not when nested fields change in place.
184
+
-**`'shallow'`** / **`'struct'`** — shallow or structural comparison for nested properties.
185
+
-**`false`** — do not decorate `result` (rare; you lose automatic MobX tracking for the result blob).
Mutation result (The same as returns the [`useMutation` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation))
222
+
223
+
::: info `observable.deep` is configurable
224
+
The badge reflects the **default**: the public `result` property is decorated as deep observable (unlike `Query`, which uses a private `_result` behind getters). Change the MobX flavour with [`resultObservable`](#resultobservable-mutationfeature) (`ref`, `shallow`, `struct`, `true`, or `false`).
Copy file name to clipboardExpand all lines: docs/api/Query.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -295,6 +295,10 @@ This field is needed for `enableOnDemand` option
295
295
296
296
Query original result (The same as returns the [`useQuery` hook](https://tanstack.com/query/latest/docs/framework/react/reference/useQuery))
297
297
298
+
::: info `observable.deep` is configurable
299
+
The badge reflects the **default**: the internal `_result` field is decorated as deep observable. You can change the MobX flavour (`ref`, `shallow`, `struct`, `true`, or `false`) with the [`resultObservable`](#resultobservable-queryfeature) query feature.
300
+
:::
301
+
298
302
### `setData(updater, options)`
299
303
300
304
Set data for current query (Uses [queryClient.setQueryData](https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientsetquerydata))
[_Can be specified using `QueryClient`_](https://js2me.github.io/mobx-tanstack-query/api/QueryClient.html#queryfeatures)
651
+
652
+
Only applies when [`lazy`](#lazy-option-queryfeature) is enabled.
653
+
654
+
After the last MobX observer stops reading the query result, the library keeps the TanStack `QueryObserver` subscription alive for an extra **`lazyDelay` milliseconds** before tearing it down. Internally this maps to the `endDelay` option of [`lazyObserve`](https://www.npmjs.com/package/yummies) from `yummies/mobx`.
655
+
656
+
Use this to avoid churn when UI code briefly mounts and unmounts (for example route transitions or conditional panels): if something starts observing the result again before the delay elapses, the existing subscription is reused and you avoid an immediate unsubscribe/resubscribe cycle.
657
+
658
+
-**Omitted or `undefined`** — teardown runs as soon as nothing observes the result (equivalent to `endDelay: false` in [`lazyObserve`](https://www.npmjs.com/package/yummies) / `yummies/mobx`).
659
+
-**A positive number** — milliseconds to wait after the last observer detaches before unsubscribing from the TanStack observer.
[_Can be specified using `QueryClient`_](https://js2me.github.io/mobx-tanstack-query/api/QueryClient.html#queryfeatures)
785
+
786
+
Chooses how MobX observes the internal TanStack Query result object (`_result`). The library applies [`annotation.observable()`](https://github.com/js2me/yummies) from `yummies/mobx`, so this maps directly to MobX flavours: `ref`, `deep`, `shallow`, `struct`, or `true` / `false`.
787
+
788
+
-**Default** — when omitted, behaviour matches **`'deep'`** (deep observability for plain objects and arrays in the result).
789
+
-**`'ref'`** — only the reference to the result object is tracked; use when the observer should react when the whole result is replaced, not when nested fields change in place.
790
+
-**`'shallow'`** / **`'struct'`** — shallow or structural comparison for nested properties.
791
+
-**`false`** — do not decorate `_result` with an observable annotation (rare; you lose automatic MobX tracking for the result blob).
792
+
793
+
Example:
794
+
795
+
```ts
796
+
const query =newQuery({
797
+
queryClient,
798
+
resultObservable: 'ref',
799
+
queryKey: ['pets'],
800
+
queryFn: async () =>api.fetchPets(),
801
+
});
802
+
```
803
+
752
804
## Recommendations
753
805
754
806
### Don't forget about `abortSignal`s or `lazy` option
0 commit comments