@tanstack/vue-query 4.13.0 → 4.13.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/build/lib/types.d.ts +1 -1
- package/build/lib/useMutation.d.ts +10 -7
- package/build/lib/useMutation.esm.js +24 -20
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +22 -18
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +24 -20
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/utils.d.ts +2 -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 +26 -19
- 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(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
|
});
|
|
@@ -4759,24 +4763,27 @@
|
|
|
4759
4763
|
};
|
|
4760
4764
|
}
|
|
4761
4765
|
function parseMutationArgs(arg1, arg2, arg3) {
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4766
|
+
const plainArg1 = vueDemi.isRef(arg1) ? arg1.value : arg1;
|
|
4767
|
+
const plainArg2 = vueDemi.isRef(arg2) ? arg2.value : arg2;
|
|
4768
|
+
let options = plainArg1;
|
|
4769
|
+
|
|
4770
|
+
if (isMutationKey(plainArg1)) {
|
|
4771
|
+
if (typeof plainArg2 === 'function') {
|
|
4772
|
+
const plainArg3 = vueDemi.isRef(arg3) ? arg3.value : arg3;
|
|
4773
|
+
options = { ...plainArg3,
|
|
4774
|
+
mutationKey: plainArg1,
|
|
4775
|
+
mutationFn: plainArg2
|
|
4769
4776
|
};
|
|
4770
4777
|
} else {
|
|
4771
|
-
options = { ...
|
|
4772
|
-
mutationKey:
|
|
4778
|
+
options = { ...plainArg2,
|
|
4779
|
+
mutationKey: plainArg1
|
|
4773
4780
|
};
|
|
4774
4781
|
}
|
|
4775
4782
|
}
|
|
4776
4783
|
|
|
4777
|
-
if (typeof
|
|
4778
|
-
options = { ...
|
|
4779
|
-
mutationFn:
|
|
4784
|
+
if (typeof plainArg1 === 'function') {
|
|
4785
|
+
options = { ...plainArg2,
|
|
4786
|
+
mutationFn: plainArg1
|
|
4780
4787
|
};
|
|
4781
4788
|
}
|
|
4782
4789
|
|