Listeners for load
events can be asynchronous and will be awaited. Listeners for unload
events need to be synchronous. Both events cannot be cancelled.
main.ts
Note that you can use both window.addEventListener
and /window.onunload
to define handlers for events. There is a major difference between them, let’s run the example:
In other words, you can register multiple window.addEventListener
"load"
or "unload"
events, but only the last loaded or window.onunload
events will be executed.