We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db39921 commit 4a6f85fCopy full SHA for 4a6f85f
service/src/shutdown.service.ts
@@ -0,0 +1,18 @@
1
+import { OnModuleDestroy } from '@nestjs/common'
2
+import { Subject } from 'rxjs'
3
+
4
+export class ShutdownService implements OnModuleDestroy {
5
+ private shutdownListener$: Subject<void> = new Subject()
6
7
+ public onModuleDestroy() {
8
+ console.log('Executing OnDestroy Hook')
9
+ }
10
11
+ public subscribeToShutdown(shutdownFn: () => void): void {
12
+ this.shutdownListener$.subscribe(() => shutdownFn())
13
14
15
+ public shutdown() {
16
+ this.shutdownListener$.next()
17
18
+}
0 commit comments