• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Valence.app.setPromptBeforeClose()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Valence.app.setPromptBeforeClose()

    I have a situation where I want to use something like this but not to prompt the user. Rather just call a function to do what I need and then let the app close. So basically I just need to know when the close app event has occurred. Is there something like this available?

  • #2
    Is your application a NAB app or one you wrote manually?

    Comment


    • #3
      Not NAB. Manual.

      Comment


      • #4
        Example capturing the close of an app:
        Code:
        (function () {
            let processed = false;
        
            function processClose() {
                if (processed) {
                    return;
                }
                processed = true;
        
                //on close logic
                // FYI :
                // if making a call to the backend, use navigator.sendBeacon()
            }
        
            window.addEventListener('pagehide', function (event) {
                if (event.persisted) {
                    return;
                }
                processClose();
            });
        })();

        Comment

        Working...
        X