Skip to content

Commit 4a6f85f

Browse files
committed
WIP shutdown service implementation
1 parent db39921 commit 4a6f85f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

service/src/shutdown.service.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)