MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / createLockController

Function createLockController

core/src/utils/lock-controller.ts:8–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6 * For example, this can be used to prevent multiple transitions from occurring at the same time.
7 */
8export const createLockController = () => {
9 let waitPromise: Promise<void>;
10
11 /**
12 * When lock() is called, the lock is claimed.
13 * Once a lock has been claimed, it cannot be claimed again until it is released.
14 * When this function gets resolved, the lock is released, allowing it to be claimed again.
15 *
16 * @example ```tsx
17 * const unlock = await this.lockController.lock();
18 * // do other stuff
19 * unlock();
20 * ```
21 */
22 const lock = async () => {
23 const p = waitPromise;
24 let resolve!: () => void;
25 waitPromise = new Promise((r) => (resolve = r));
26 if (p !== undefined) {
27 await p;
28 }
29 return resolve;
30 };
31
32 return {
33 lock,
34 };
35};

Callers 8

AlertClass · 0.90
ActionSheetClass · 0.90
RouterOutletClass · 0.90
PopoverClass · 0.90
LoadingClass · 0.90
PickerClass · 0.90
ModalClass · 0.90
ToastClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected