Emit
@tsed/socketio
Usage
typescript
import { Emit } from "@tsed/socketio";
See /packages/third-parties/socketio/src/types/decorators/emit.ts.
Overview
ts
function Emit(eventName: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
Description
Emit the response to the client.
With the @Emit
decorator, the method will accept a return type (Promise or not).
Example
typescript
@SocketService("/nsp")
export class MyWS {
@Input("event")
@Emit("returnEvent")
async myMethod(@Args(0) data: any, @Nsp socket): Promise<any> {
return Promise.resolve({data})
}
}