# Decorator Emit
DecoratorModule | import { Emit } from "@tsed/socketio" |
---|---|
Source | /packages/socketio/src/decorators/emit.ts |
# Overview
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
@SocketService("/nsp")
export class MyWS {
@Input("event")
@Emit("returnEvent")
async myMethod(@Args(0) data: any, @Nsp socket): Promise<any> {
return Promise.resolve({data})
}
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Other topics
- Session & cookies
- Passport.js
- Keycloak
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- AWS
- Seq
- OIDC
- Stripe
- Controllers
- Providers
- Model
- JsonMapper
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Exceptions
- Throw HTTP Exceptions
- Cache
- Hooks
- Response Filter
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing
- Customize 404