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 / ResourceEvent
ResourceEvent(
resourceEvent
): (target
,propertyKey
,descriptor
) =>void
A decorator that registers a method to be called when a specific resource event occurs.
The @ResourceEvent
decorator is used to execute a method in response to resource start or stop events.
The method decorated with @ResourceEvent
will be called automatically when the specified event occurs for the current resource.
Events:
'start'
: The method will be called when the resource starts.'stop'
: The method will be called when the resource stops.• resourceEvent: "start"
| "stop"
The type of resource event to listen for. Must be either 'start'
or 'stop'
.
Function
• target: unknown
• propertyKey: string
• descriptor: PropertyDescriptor
void
class MyScript {
@ResourceEvent('start')
onStart() {
console.log('Resource started');
}
@ResourceEvent('stop')
onStop() {
console.log('Resource stopped');
}
}