@tanstack/vue-query 4.13.0 → 4.13.1
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/build/lib/types.d.ts +1 -1
- package/build/lib/useMutation.d.ts +10 -7
- package/build/lib/useMutation.esm.js +23 -16
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +21 -14
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +23 -16
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/utils.d.ts +3 -1
- package/build/lib/utils.esm.js +4 -1
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +4 -0
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +4 -1
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +24 -14
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
|
@@ -3121,6 +3121,9 @@
|
|
|
3121
3121
|
function isQueryKey(value) {
|
|
3122
3122
|
return Array.isArray(value);
|
|
3123
3123
|
}
|
|
3124
|
+
function isMutationKey(value) {
|
|
3125
|
+
return Array.isArray(vueDemi.isRef(value) ? value.value : value);
|
|
3126
|
+
}
|
|
3124
3127
|
function updateState(state, update) {
|
|
3125
3128
|
Object.keys(state).forEach(key => {
|
|
3126
3129
|
state[key] = update[key];
|
|
@@ -4727,12 +4730,13 @@
|
|
|
4727
4730
|
}
|
|
4728
4731
|
|
|
4729
4732
|
function useMutation(arg1, arg2, arg3) {
|
|
4730
|
-
var _options$
|
|
4733
|
+
var _options$value$queryC;
|
|
4731
4734
|
|
|
4732
|
-
const options =
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
const
|
|
4735
|
+
const options = vueDemi.computed(() => {
|
|
4736
|
+
return parseMutationArgs(arg1, arg2, arg3);
|
|
4737
|
+
});
|
|
4738
|
+
const queryClient = (_options$value$queryC = options.value.queryClient) != null ? _options$value$queryC : useQueryClient(options.value.queryClientKey);
|
|
4739
|
+
const observer = new MutationObserver(queryClient, queryClient.defaultMutationOptions(options.value));
|
|
4736
4740
|
const state = vueDemi.reactive(observer.getCurrentResult());
|
|
4737
4741
|
const unsubscribe = observer.subscribe(result => {
|
|
4738
4742
|
updateState(state, result);
|
|
@@ -4743,8 +4747,8 @@
|
|
|
4743
4747
|
});
|
|
4744
4748
|
};
|
|
4745
4749
|
|
|
4746
|
-
vueDemi.watch(
|
|
4747
|
-
observer.setOptions(queryClient.defaultMutationOptions(
|
|
4750
|
+
vueDemi.watch(options, () => {
|
|
4751
|
+
observer.setOptions(queryClient.defaultMutationOptions(options.value));
|
|
4748
4752
|
}, {
|
|
4749
4753
|
deep: true
|
|
4750
4754
|
});
|
|
@@ -4761,11 +4765,14 @@
|
|
|
4761
4765
|
function parseMutationArgs(arg1, arg2, arg3) {
|
|
4762
4766
|
let options = arg1;
|
|
4763
4767
|
|
|
4764
|
-
if (
|
|
4765
|
-
|
|
4766
|
-
|
|
4768
|
+
if (isMutationKey(arg1)) {
|
|
4769
|
+
const plainFn = vueDemi.isRef(arg2) ? arg2.value : arg2;
|
|
4770
|
+
const plainOptions = vueDemi.isRef(arg3) ? arg3.value : arg3;
|
|
4771
|
+
|
|
4772
|
+
if (typeof plainFn === 'function') {
|
|
4773
|
+
options = { ...plainOptions,
|
|
4767
4774
|
mutationKey: arg1,
|
|
4768
|
-
mutationFn:
|
|
4775
|
+
mutationFn: plainFn
|
|
4769
4776
|
};
|
|
4770
4777
|
} else {
|
|
4771
4778
|
options = { ...arg2,
|
|
@@ -4774,9 +4781,12 @@
|
|
|
4774
4781
|
}
|
|
4775
4782
|
}
|
|
4776
4783
|
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4784
|
+
const plainFn = vueDemi.isRef(arg1) ? arg1.value : arg1;
|
|
4785
|
+
const plainOptions = vueDemi.isRef(arg2) ? arg2.value : arg2;
|
|
4786
|
+
|
|
4787
|
+
if (typeof plainFn === 'function') {
|
|
4788
|
+
options = { ...plainOptions,
|
|
4789
|
+
mutationFn: plainFn
|
|
4780
4790
|
};
|
|
4781
4791
|
}
|
|
4782
4792
|
|