Hi,
We want to call an action e.g. to clear session (customized) on the OnDestroy event. Just wondering if it triggers on closing the browser.
Regards,
JC
When you close your browser, the session should also end (so long as you don't have another window open), regardless if your OnDestroy event gets triggered or not.
You can use the OnDestroy event of the BottomBar block. But, can you give us more details about your scenario case?
Basically we don't have a login and just use Session Tokens when the user accesses a specific transaction. The screens are anonymous. When the user accesses the transaction in a proper way, a token is created and is stored in the database with reference to that transaction id. On 'logout', there is a process that basically deletes this record so that it will invalidate the 'session'.
I am already calling this 'logout' process on the OnDestroy event of a screen. Now just wondering if this triggers when you close the browser.
Yes, when you close the browser, will be trigger the OnDestroy, and clean DOM.
Nuno Miguel Verdasca wrote:
Although now we tried a pure JS approach, still had to try this one out. Unfortunately, didn't work. Created a screen action OnDestroy for a screen and just call a CreateEntity for a record. Moving out of that screen created a new record. Closing the browser didn't.
Hi Juan Carlos,
Did you manage to find a clear answer to your question?
From my tests with OnDestroy, I saw that indeed it doesn't get triggered when closing the browser, but I was wondering if this is the expected behaviour or I'm doing something wrong, haha.KR,Andrei
No, the OnDestroy event does not trigger when the browser or browser tab is closed. The event is only called when navigating to another Screen within a Reactive (or Mobile) application.
From the docs:
The On Destroy event handler executes when the Screen or Block is going to be destroyed.
In Screens, this event happens when the transition to the new Screen ends.
In Blocks, this event happens before the Block is removed from the DOM.
For Juan Carlos' original use-case, the best solution is to: