OLD | NEW |
1 <meta name="doc-family" content="apps"> | 1 <meta name="doc-family" content="apps"> |
2 <div id="pageData-name" class="pageData">Manage App Lifecycle</div> | 2 <h1>Manage App Lifecycle</h1> |
3 <div id="pageData-showTOC" class="pageData">true</div> | 3 |
4 | 4 |
5 <p> | 5 <p> |
6 The app runtime and event page are responsible | 6 The app runtime and event page are responsible |
7 for managing the app lifecycle. | 7 for managing the app lifecycle. |
8 The app runtime manages app installation, | 8 The app runtime manages app installation, |
9 controls the event page, | 9 controls the event page, |
10 and can shutdown the app at anytime. | 10 and can shutdown the app at anytime. |
11 The event page listens out for events from the app runtime | 11 The event page listens out for events from the app runtime |
12 and manages what gets launched and how. | 12 and manages what gets launched and how. |
13 </p> | 13 </p> |
14 | 14 |
15 <h2 id="lifecycle">How the lifecycle works</h2> | 15 <h2 id="lifecycle">How the lifecycle works</h2> |
16 | 16 |
17 <p> | 17 <p> |
18 The app runtime loads the event page | 18 The app runtime loads the event page |
19 from a user's desktop and | 19 from a user's desktop and |
20 the <code>onLaunch()</code> event is fired. | 20 the <code>onLaunch()</code> event is fired. |
21 This event tells the event page what windows | 21 This event tells the event page what windows |
22 to launch and their dimensions. | 22 to launch and their dimensions. |
23 The lifecycle diagram here isn't the nicest to look at, | 23 The lifecycle diagram here isn't the nicest to look at, |
24 but it's practical (and we will make it nicer soon). | 24 but it's practical (and we will make it nicer soon). |
25 </p> | 25 </p> |
26 | 26 |
27 <img src="../images/applifecycle.png" | 27 <img src="{{static}}/images/applifecycle.png" |
28 width="444" | 28 width="444" |
29 height="329" | 29 height="329" |
30 alt="how app lifecycle works"> | 30 alt="how app lifecycle works"> |
31 | 31 |
32 <p> | 32 <p> |
33 When the event page has no executing JavaScript, | 33 When the event page has no executing JavaScript, |
34 no pending callbacks, and no open windows, | 34 no pending callbacks, and no open windows, |
35 the runtime unloads the event page and closes the app. | 35 the runtime unloads the event page and closes the app. |
36 Before unloading the event page, | 36 Before unloading the event page, |
37 the <code>onSuspend()</code> event is fired. | 37 the <code>onSuspend()</code> event is fired. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 while handling this event are not guaranteed to complete. | 220 while handling this event are not guaranteed to complete. |
221 Keep the clean-up tasks synchronous and simple. | 221 Keep the clean-up tasks synchronous and simple. |
222 </p> | 222 </p> |
223 | 223 |
224 <pre> | 224 <pre> |
225 chrome.runtime.onSuspend.addListener(function() { | 225 chrome.runtime.onSuspend.addListener(function() { |
226 // Do some simple clean-up tasks. | 226 // Do some simple clean-up tasks. |
227 }); | 227 }); |
228 </pre> | 228 </pre> |
229 | 229 |
230 <p class="backtotop"><a href="#top">Back to top</a></p> | 230 <p class="backtotop"><a href="#top">Back to top</a></p> |
OLD | NEW |