useLockFn

Add lock to an async function to prevent parallel executions.

Examples

Basic usage

Submit count:0

Prevent duplicated submits

Before the `submit` function finishes, the other click actions will be ignored.

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