a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Shared / Event
Event(
eventName
): (target
,propertyKey
,descriptor
) =>void
A decorator that subscribes a method to a specified local event.
The @Event
decorator is used to associate a method with a named event. When the specified event is triggered, the decorated method will be automatically called with the event’s arguments.
Usage:
Example:
class EventHandler {
@Event('userLoggedIn')
onUserLoggedIn(userId: number, userName: string) {
console.log(`User logged in: ${userName} (ID: ${userId})`);
}
}
Parameters:
eventName
: The name of the event to listen for. The method decorated with @Event
will be called whenever this event is triggered.Note: Ensure that the event name matches the one used in the event system, and the method should match the expected signature of the event arguments.
• eventName: string
The name of the event to subscribe to.
Function
A method decorator that subscribes the decorated method to the specified event.
• target: object
• propertyKey: string
• descriptor: PropertyDescriptor
void