diff --git a/runtime/reference/deno_namespace_apis.md b/runtime/reference/deno_namespace_apis.md index 4a4cebb91..b92b99d59 100644 --- a/runtime/reference/deno_namespace_apis.md +++ b/runtime/reference/deno_namespace_apis.md @@ -753,7 +753,8 @@ Deno supports browser compatible lifecycle events: Scheduling more asynchronous work (like timers or network requests) will cause the program to continue. - [`unload`](https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event): - fired when the document or a child resource is being unloaded. + fired when the program has no more work to do. Scheduling more asynchronous + work (like timers or network requests) **does not** keep the program alive. - [`unhandledrejection`](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event): fired when a promise that has no rejection handler is rejected, ie. a promise that has no `.catch()` handler or a second argument to `.then()`. @@ -762,13 +763,36 @@ Deno supports browser compatible lifecycle events: rejected. This event is fired only if there's `unhandledrejection` listener installed that prevents propagation of the event (which would result in the program terminating with an error). +- [`error`](https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event): + TODO(bartlomieju) + +Deno also support Node.js compatible lifecycle events: + +- [`process.on("beforeExit")`](https://nodejs.org/api/process.html#event-beforeexit): + fired when the event loop has no more work to do and is about to exit. + Scheduling more asynchronous work (like timers or network requests) will cause + the program to continue. Counterpart to `beforeunload` Web event. Fires + immediatelly after `beforeunload` event. +- [`process.on("exit")`](https://nodejs.org/api/process.html#event-exit): fired + when the program has no more work to do. Scheduling more asynchronous work + (like timers or network requests) **does not** keep the program alive. + Counterpart to `unload` Web event. Fired immediately after `unload` event. +- [`process.on("rejectionHandled")`](https://nodejs.org/api/process.html#event-rejectionhandled): + TODO(bartlomieju) +- [`process.on("uncaughtException")`](https://nodejs.org/api/process.html#event-uncaughtexception): + TODO(bartlomieju) Counterpart to `error` Web event. Fires immediatelly after + `error` event. +- [`process.on("unhandledRejection")`](https://nodejs.org/api/process.html#event-unhandledrejection): + TODO(bartlomieju) Counterpart to `unhandledrejection` Web event. Fires + immediatelly after `unhandledrejection` event. You can use these events to provide setup and cleanup code in your program. -Listeners for `load` events can be asynchronous and will be awaited, this event -cannot be canceled. Listeners for `beforeunload` need to be synchronous and can -be cancelled to keep the program running. Listeners for `unload` events need to -be synchronous and cannot be cancelled. +// TODO(bartlomieju): what about Node.js listeners? Are they awaited? Listeners +for `load` events can be asynchronous and will be awaited, this event cannot be +canceled. Listeners for `beforeunload` need to be synchronous and can be +cancelled to keep the program running. Listeners for `unload` events need to be +synchronous and cannot be cancelled. **main.ts**