Skip to content
On this page

useLockFn

给异步函数加竞争锁的 Hook

代码演示

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

参数说明类型
fn增加了竞态锁的函数(...args: any[]) => Promise<any>

Params

参数说明类型默认值
fn需要增加竞态锁的函数(...args: any[]) => Promise<any>-

Source

源码文档示例