Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The documentation for the <code>start</code> function is a little misleading. </p> <p>When you call <code>start</code>, <code>WinJS.Application</code> begins to queue and dispatch events, including those which are emitted by <code>Windows.UI.WebUI.WebUIApplication</code>. One of these events is <code>activated</code>, which is what leads to your handler function being called.</p> <p>The important point is that the queuing doesn't begin until you call <code>start</code>. Any events that are emitted by <code>WebUIApplication</code> before the queuing begins are lost forever. </p> <p>This is the situation you have created by delaying your call to <code>start</code>: the <code>activated</code> event is sent by <code>WebUIApplication</code> before the <code>WinJS.Application</code> queue has been set up. The <code>activated</code> event is never received by <code>WinJS.Application</code> and so your handler function is never invoked.</p> <p>I know you are just trying to figure out the life cycle, but there isn't a reason to delay your call to the <code>start</code> function in real life. The only way to get the effect you are trying to create in your code is to place the Promise inside the <code>onactivated</code> handler function, like this:</p> <pre><code>(function () { var app = WinJS.Application; app.onactivated = function () { document.getElementById("pageTitle").innerText += "Gettin' there..."; WinJS.Promise.timeout(5000).then(function () { document.getElementById("pageTitle").innerText = "Rock it!"; }); document.getElementById("pageTitle").innerText += "Almost made it..."; }; app.start(); })(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload