| ... | @@ -45,6 +45,7 @@ export interface UseMutateResultBase<Args extends unknown[], Result> { | ... | @@ -45,6 +45,7 @@ export interface UseMutateResultBase<Args extends unknown[], Result> { |
| 45 | ..._: [...args: Args, options: RunOptions<Result>] | 45 | ..._: [...args: Args, options: RunOptions<Result>] |
| 46 | ) => Promise<Result>; | 46 | ) => Promise<Result>; |
| 47 | clear: () => void; | 47 | clear: () => void; |
| | 48 | args: Args | undefined; |
| 48 | } | 49 | } |
| 49 | | 50 | |
| 50 | export interface UseMutateSuccess<Result> { | 51 | export interface UseMutateSuccess<Result> { |
| ... | @@ -175,7 +176,11 @@ class Observer<Args extends unknown[], Result> { | ... | @@ -175,7 +176,11 @@ class Observer<Args extends unknown[], Result> { |
| 175 | run(...args: Args) { | 176 | run(...args: Args) { |
| 176 | const mutation = this.mutation; | 177 | const mutation = this.mutation; |
| 177 | if (!mutation) return; | 178 | if (!mutation) return; |
| | 179 | const argsChanged = this.currentArgs !== args; |
| 178 | this.currentArgs = args; | 180 | this.currentArgs = args; |
| | 181 | if (argsChanged && this.watched.has("args")) { |
| | 182 | this.setRerender(Math.random()); |
| | 183 | } |
| 179 | const key = mutation.key(args); | 184 | const key = mutation.key(args); |
| 180 | if (key !== this.currentKey) { | 185 | if (key !== this.currentKey) { |
| 181 | this.currentKey = key; | 186 | this.currentKey = key; |
| ... | @@ -249,7 +254,11 @@ class Observer<Args extends unknown[], Result> { | ... | @@ -249,7 +254,11 @@ class Observer<Args extends unknown[], Result> { |
| 249 | const args = array.slice() as Args; | 254 | const args = array.slice() as Args; |
| 250 | const options = args.pop() as RunOptions<Result>; | 255 | const options = args.pop() as RunOptions<Result>; |
| 251 | | 256 | |
| | 257 | const argsChanged = this.currentArgs !== args; |
| 252 | this.currentArgs = args; | 258 | this.currentArgs = args; |
| | 259 | if (argsChanged && this.watched.has("args")) { |
| | 260 | this.setRerender(Math.random()); |
| | 261 | } |
| 253 | const key = mutation.key(args); | 262 | const key = mutation.key(args); |
| 254 | | 263 | |
| 255 | // Set up subscription if key changed | 264 | // Set up subscription if key changed |
| ... | @@ -347,6 +356,10 @@ class Observer<Args extends unknown[], Result> { | ... | @@ -347,6 +356,10 @@ class Observer<Args extends unknown[], Result> { |
| 347 | self.watched.add("isOptimisticData"); | 356 | self.watched.add("isOptimisticData"); |
| 348 | return self.state.isOptimisticData; | 357 | return self.state.isOptimisticData; |
| 349 | }, | 358 | }, |
| | 359 | get args() { |
| | 360 | self.watched.add("args"); |
| | 361 | return self.currentArgs ?? undefined; |
| | 362 | }, |
| 350 | } as UseMutateResult<Args, Result>))(this); | 363 | } as UseMutateResult<Args, Result>))(this); |
| 351 | } | 364 | } |
| 352 | | 365 | |