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,3 +1,4 @@
import { bindThis } from '@/decorators.js';
import type Connection from '.';
/**
@ -43,6 +44,7 @@ export default abstract class Channel {
this.connection = connection;
}
@bindThis
public send(typeOrPayload: any, payload?: any) {
const type = payload === undefined ? typeOrPayload.type : typeOrPayload;
const body = payload === undefined ? typeOrPayload.body : payload;