Home > @imqueue/rpc > lock

lock() function

Creates a @lock() method decorator. Concurrent calls to the decorated method that share the same arguments are coalesced: only the first call is executed, and all the others resolve with its result. Call similarity is determined by the method's argument values. The returned decorator is dual-mode: it works both as a standard (TC39) and as a legacy method decorator.

Signature:

export declare function lock(enabledOrOptions?: boolean | LockOptions): any;

Parameters

Parameter

Type

Description

enabledOrOptions

boolean | LockOptions

(Optional) whether locking is enabled, or the lock options {Function} - a dual-mode method decorator

Returns:

any