Skip to main content

Function: createFakeLocks()

createFakeLocks(failing?): object

Defined in: src/testing/locks.ts:11

Fake Web Locks shared by any number of pretend windows: ifAvailable requests get no lock while another holds it, and steal takes it, failing the holder's request with an AbortError. A lock is let go when its callback's promise settles. With failing, every request fails (as on a page where locks can't be used).

Parameters​

failing?​

boolean = false

Returns​

isHeld​

isHeld: (name) => boolean

Whether a lock is held

Parameters​

name​

string

Returns​

boolean

locks​

locks: LockManager

Example​

const { locks, isHeld } = createFakeLocks();
new LayerAutosave(canvas, store, { locks }).start();
isHeld("paintcanvas:test"); // true