Skip to main content

Function: On()

On(eventName?): MethodDecorator

Method decorator that binds a controller method to the ON event type.

Parameters

eventName?

string

Optional custom event name; if omitted, the method name will be used.

Returns

MethodDecorator

A method decorator that registers the decorated method as an event handler for EventType.ON in the controller’s metadata.

Example

@Controller()
class MyController {
@On('playerJoined')
handlePlayerJoin(data: PlayerData) {
// ...handle player join...
}
}