I need to call a query when app is closed using global function(beforeunload)
It works for other events like visibilitychnage, but not for beforeunload? caa i know why?
Also please I think following improvements can also be helpful.
Asynchronous operations: The beforeunload event doesn't wait for asynchronous operations like your query trigger to complete. By the time your query starts executing, the page might already be unloaded.
Event handler timing: Unlike visibilitychange, which allows time for operations, beforeunload has strict timing constraints.
Return value requirement: For beforeunload to properly work, you need to return a value from the handler.
Can you give more context about the query? Like what is the exact feature you are trying to implement? I thinking of modifying our requirement or completely coming with a custom solution. So please can you explain more?
Currently we are blocked by:
Limited control: You cannot fully control the closing process.
Time constraints: Even with the confirmation dialog, the query execution time is limited. If your query takes too long, it still might not complete.