refactor: introduce bindThis decorator to bind this automaticaly

This commit is contained in:
syuilo
2022-12-04 15:03:09 +09:00
parent e73581f715
commit bbb49457f9
199 changed files with 969 additions and 96 deletions

View File

@@ -3,6 +3,7 @@ import si from 'systeminformation';
import Xev from 'xev';
import * as osUtils from 'os-utils';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
import type { OnApplicationShutdown } from '@nestjs/common';
const ev = new Xev();
@@ -23,6 +24,7 @@ export class ServerStatsService implements OnApplicationShutdown {
/**
* Report server stats regularly
*/
@bindThis
public start(): void {
const log = [] as any[];
@@ -61,6 +63,7 @@ export class ServerStatsService implements OnApplicationShutdown {
this.intervalId = setInterval(tick, interval);
}
@bindThis
public onApplicationShutdown(signal?: string | undefined) {
clearInterval(this.intervalId);
}