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 / Retry

Function: Retry()

Retry(attempts, delay): (target, propertyKey, descriptor) => void

A decorator to automatically retry a method upon failure.

This decorator retries the decorated method a specified number of times, with a delay between each attempt. If all attempts fail, the last error will be thrown.

Parameters

attempts: number

The number of retry attempts before failing.

delay: number

The delay in milliseconds between each retry attempt.

Returns

Function

A method decorator that applies the retry logic.

Parameters

target: object

propertyKey: string | symbol

descriptor: TypedPropertyDescriptor<Function>

Returns

void

Example

import { Retry } from 'fivem-ts/shared/decorators';

class MyService {
    @Retry(3, 1000)
    async unstableMethod(): Promise<void> {
        // Some operation that might fail
    }
}

Defined in

shared/decorators/core/Retry.ts:29