Skip to content

useLockFn ​

Add lock to an async function to prevent parallel executions.

Code demonstration ​

API ​

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

Source · Document · Demo

Released under the MIT License.