Skip to content

Commit d433666

Browse files
Merge pull request #2447 from SpekalsG3/spekalsg3-docs/onmoduleinit-order-info
docs(onmoduleinit): add info about onmoduleinit execution order
2 parents da3009f + d18662a commit d433666

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 **Hint** Execution order of `onModuleInit()` and `onApplicationBootstrap()` directly depends on the order of module imports, awaiting the previous hook.
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)