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