Skip to content
On this page

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

PropertyDescriptionType
fnThe async function with lock(...args: any[]) => Promise<any>

Params

PropertyDescriptionTypeDefault
fnAn async function(...args: any[]) => Promise<any>-

Source

SourceDocsDemo