1

I have a Tauri app which calls some rust commands with the invoke function a bunch of times. The problem is that when the user changes the page while the request is still going, the request itself does not stop and keeps running in background, generating an error when it completes since the page I was supposed to display the result is not there anymore.

I tried to see if the invoke function had an abort method to stop the command when the page unloads but nothing.

Do you guys have any idea how to kill the promise of the invoke when the user changes the page?

Neku80
  • 361
  • 4
  • 16
  • I successfully achieved that with `tauri::State` and a command that stops a command by name, but this has some drawbacks: it may not stop the command immediately, and unless the command is async it does not work at all. – Chayim Friedman May 14 '23 at 13:21
  • How can a command stop another command, is there a tauri api for that? – Neku80 May 15 '23 at 08:38
  • It can set an `AtomicBool` in `tauri::State` that the other command checks. – Chayim Friedman May 15 '23 at 09:55
  • Which command checks? I still don't get how to kill the running command. Can you provide some code example in a solution please? – Neku80 May 15 '23 at 10:26

0 Answers0