Hello, I am working on an upgraded version of the rspc (https://rspc.dev) plugin for Tauri.
When using a regular Websocket connection with rspc all of the subscriptions are shut down on the server when the page reloads due to the connection handler being dropped. I recently became aware that my existing Tauri plugin does not cleanup subscriptions at all due to to the way I built it which is pretty problematic.
My goal is to have all of the subscriptions be shutdown every time the webpage refreshes as that is what happens on a regular websocket connection. I am struggling to work out how I would do this with the Tauri plugin API. My high level goal is to run some Rust code when the user changes pages.
An optimal solution here would be if there is a window.on_page_reload method where I could register a callback or a WindowEvent::Reload variant which I can listen for although I can't seem to find either of these in the API docs.
As an alternative if either of those don't exist, I think I can workaround this if Tauri provides a way to uniquely identify the window. This would be through an API along the lines of window.id() -> i32 but I also can't find something similar to that in the API docs.
I have thrown some commented out pseudocode into the existing code of the rspc plugin to try and illustrate my goals if my explanation isn't clear. In the context of the code, my goal is to send a message on shutdown_tx from within the on_page_load callback when the user navigates away from that specific page load event that triggered the on_page_load callback. Doing so will shutdown all of the rspc subscriptions for the outgoing page and then the on_page_load will be called again for the incoming page, spinning up a fresh set of state.
https://github.com/oscartbeaumont/rspc/blob/executor-v2/src/integrations/tauri.rs