Jesus
Jesus

Reputation: 8586

How to execute an action before close metro app WinJS

I want to trigger a function before closing my metro app but I don't know where such as

app.onactivated = function (args){
  //all the actions here will be executed on app's activation
}

I want something for deactivation or app's closure, what's the proper way to do this in WinJS

Upvotes: 1

Views: 505

Answers (3)

Jeremy Foster
Jeremy Foster

Reputation: 4763

Look at the documentation for both onunload and oncheckpoint. There are differences and you may need one or the other.

Upvotes: 3

Jordan Kasper
Jordan Kasper

Reputation: 13273

I think you'll actually want to tie into the WinJS.Application unload event, which is really just a wrapper for window.onunload, but is the "Windows 8" way to do it:

WinJS.Application.addEventListener("unload", function(e) {
    // do any needed clean up
});

Upvotes: 2

PTwr
PTwr

Reputation: 1273

If I am not mistaken, it will be onunload event.

"Occurs when the application is about to be unloaded." - MSDN

Upvotes: 3

Related Questions