diff options
author | Chris Knight <cknight1234@gmail.com> | 2020-05-27 03:12:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 22:12:02 -0400 |
commit | 27708fe87316d11b8d99459db257d381ee049430 (patch) | |
tree | 0cd12b3dc170f71bad5c01212d313d2cc699f69b /docs/runtime/program_lifecycle.md | |
parent | f7b4523178b01a7e485e98443f03a6973df3e376 (diff) |
doc: various runtime doc updates (#5885)
Diffstat (limited to 'docs/runtime/program_lifecycle.md')
-rw-r--r-- | docs/runtime/program_lifecycle.md | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/docs/runtime/program_lifecycle.md b/docs/runtime/program_lifecycle.md index 4a94d6724..7f6035048 100644 --- a/docs/runtime/program_lifecycle.md +++ b/docs/runtime/program_lifecycle.md @@ -8,8 +8,9 @@ for `unload` events need to be synchronous. Both events cannot be cancelled. Example: +**main.ts** + ```ts -// main.ts import "./imported.ts"; const handler = (e: Event): void => { @@ -29,8 +30,11 @@ window.onunload = (e: Event): void => { }; console.log("log from main script"); +``` + +**imported.ts** -// imported.ts +```ts const handler = (e: Event): void => { console.log(`got ${e.type} event in event handler (imported)`); }; @@ -68,3 +72,7 @@ got unload event in event handler (main) All listeners added using `window.addEventListener` were run, but `window.onload` and `window.onunload` defined in `main.ts` overrode handlers defined in `imported.ts`. + +In other words, you can register multiple `window.addEventListener` `"load"` or +`"unload"` events, but only the last loaded `window.onload` or `window.onunload` +events will be executed. |