Function createPromiseLock

  • Create a promise lock

    Example

    const lock = createPromiseLock()

    lock.run(async () => {
    await doSomething()
    })

    // in anther context:
    await lock.wait() // it will wait all tasking finished

    Returns {
        clear(): void;
        isWaiting(): boolean;
        run<T>(fn: (() => Promise<T>)): Promise<T>;
        wait(): Promise<void>;
    }

    • clear:function
    • isWaiting:function
    • run:function
      • Type Parameters

        • T = void

        Parameters

        • fn: (() => Promise<T>)
            • (): Promise<T>
            • Returns Promise<T>

        Returns Promise<T>

    • wait:function

Generated using TypeDoc