useLockFn
Add lock to an async function to prevent parallel executions.
Code demonstration
API
function useLockFn<P extends any[] = any[], V extends any = any>(
fn: (...args: P) => Promise<V>
): fn: (...args: P) => Promise<V | undefined>;
function useLockFn<P extends any[] = any[], V extends any = any>(
fn: (...args: P) => Promise<V>
): fn: (...args: P) => Promise<V | undefined>;
Result
Property | Description | Type |
---|---|---|
fn | The async function with lock | (...args: any[]) => Promise<any> |
Params
Property | Description | Type | Default |
---|---|---|---|
fn | An async function | (...args: any[]) => Promise<any> | - |