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