Skip to content

Commit 61978f9

Browse files
committed
docs(onmoduleinit): add info about onmoduleinit execution order
1 parent 81a4ae5 commit 61978f9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

content/fundamentals/lifecycle-events.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ In the following table, `onModuleDestroy`, `beforeApplicationShutdown` and `onAp
2626

2727
> warning **Warning** The lifecycle hooks listed above are not triggered for **request-scoped** classes. Request-scoped classes are not tied to the application lifecycle and their lifespan is unpredictable. They are exclusively created for each request and automatically garbage-collected after the response is sent.
2828
29+
> info **Info** Execution order of `onModuleInit()` and `onApplicationBootstrap()` directly depends on the order of module imports, awaiting previous hook. If services are imported via providers option then `onModuleInit()` and `onApplicationBootstrap()` will be called simultaneously.
30+
2931
#### Usage
3032

3133
Each lifecycle hook is represented by an interface. Interfaces are technically optional because they do not exist after TypeScript compilation. Nonetheless, it's good practice to use them in order to benefit from strong typing and editor tooling. To register a lifecycle hook, implement the appropriate interface. For example, to register a method to be called during module initialization on a particular class (e.g., Controller, Provider or Module), implement the `OnModuleInit` interface by supplying an `onModuleInit()` method, as shown below:

0 commit comments

Comments
 (0)