Core
Framework v2.x
2

lock #

Available since 2.9.0

Tries to lock a resource.

lock(): Promise<boolean>

Returns #

Returns a promise, resolving to a boolean value.

If a timeout (see constructor options) has been set with a number greater than or equal to 0, then you must check the boolean result to verify if the lock has been acquired or not.

If the lock timeout was set to -1, the promise will only be resolved once the lock has successfully been acquired, and the boolean result is always true.