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 / Thread
Thread(
delay
): (target
,propertyKey
,descriptor
) =>void
A decorator that executes a method periodically at a specified interval.
The @Thread
decorator schedules the decorated method to be executed repeatedly after a specified delay.
This is useful for scenarios where you need a method to be run on a regular interval, such as updating
status, checking conditions, or performing background tasks.
• delay: number
The interval in milliseconds between successive executions of the method.
Function
A decorator function that modifies the behavior of the method to run periodically.
• target: unknown
• propertyKey: string
• descriptor: PropertyDescriptor
void
class StatusUpdater {
@Thread(5000) // Runs every 5 seconds
public updateStatus() {
console.log('Updating status...');
}
}
const updater = new StatusUpdater();
// The `updateStatus` method will now be called every 5 seconds.