@fivem-ts/shared
Version:
FiveM Typescript wrapper shared part
27 lines (26 loc) • 1.01 kB
TypeScript
import 'reflect-metadata';
/**
* 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.
*
* @example
* ```ts
* 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.
* ```
*
* @param delay The interval in milliseconds between successive executions of the method.
*
* @returns A decorator function that modifies the behavior of the method to run periodically.
*/
export declare function Thread(delay: number): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => void;