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

@ -1,4 +1,5 @@
import { Inject, Injectable } from '@nestjs/common';
import { bindThis } from '@/decorators.js';
import Channel from '../channel.js';
class AdminChannel extends Channel {
@ -6,6 +7,7 @@ class AdminChannel extends Channel {
public static shouldShare = true;
public static requireCredential = true;
@bindThis
public async init(params: any) {
// Subscribe admin stream
this.subscriber.on(`adminStream:${this.user!.id}`, data => {
@ -23,6 +25,7 @@ export class AdminChannelService {
) {
}
@bindThis
public create(id: string, connection: Channel['connection']): AdminChannel {
return new AdminChannel(
id,