fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Shared / ResourceEvent

Function: 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:

Parameters

resourceEvent: "start" | "stop"

The type of resource event to listen for. Must be either 'start' or 'stop'.

Returns

Function

Parameters

target: unknown

propertyKey: string

descriptor: PropertyDescriptor

Returns

void

Example

class MyScript {
    @ResourceEvent('start')
    onStart() {
        console.log('Resource started');
    }

    @ResourceEvent('stop')
    onStop() {
        console.log('Resource stopped');
    }
}

Defined in

shared/decorators/events/resourceEvent.ts:30