Skip to main content
Version: v2.2.0

Class: ProxyWrapper

Defined in: src/utils/ProxyWrapper.ts:15

A wrapper class that manages a proxy and its associated events. The ProxyWrapper encapsulates the functionality of proxy operations and ensures that event listeners are triggered appropriately. It also provides the ability to revoke the proxy and manage traceability.

Example​

const proxyWrapper = new ProxyWrapper({ id: 'proxy1', nexo: someNexoInstance, traceable: true, revoke: revokeFunction });
proxyWrapper.revoke(); // This will revoke the proxy.

Extends​

Implements​

  • ProxyWrapper

Constructors​

new ProxyWrapper()​

new ProxyWrapper(data): ProxyWrapper

Defined in: src/utils/ProxyWrapper.ts:44

Creates an instance of ProxyWrapper. This constructor initializes the wrapper with the provided data and sets up the proxy's traceability. If the proxy is not traceable, a sandbox is created.

Parameters​

data​

The data for initializing the proxy wrapper, including id, nexo, traceable flag, and revoke function.

id​

string

nexo​

Nexo

revoke​

FunctionLike<[], void>

traceable​

boolean

Returns​

ProxyWrapper

Example​

const proxyWrapper = new ProxyWrapper({ id: 'proxy1', nexo: someNexoInstance, traceable: true, revoke: revokeFunction });
// Initializes the ProxyWrapper instance.

Overrides​

NexoEmitter.constructor

Properties​

id​

readonly id: string

Defined in: src/utils/ProxyWrapper.ts:20

The unique identifier for the proxy wrapper.

Implementation of​

nx.ProxyWrapper.id


nexo​

readonly nexo: Nexo

Defined in: src/utils/ProxyWrapper.ts:23

The Nexo instance associated with this proxy wrapper.

Implementation of​

nx.ProxyWrapper.nexo


sandbox​

readonly sandbox: void | Traceable

Defined in: src/utils/ProxyWrapper.ts:26

The sandbox for the proxy if it is not traceable, otherwise undefined.

Implementation of​

nx.ProxyWrapper.sandbox

Accessors​

revoked​

Get Signature​

get revoked(): boolean

Defined in: src/utils/ProxyWrapper.ts:85

A getter that returns whether the proxy has been revoked. This value is true if the proxy was revoked, otherwise false.

Example​
const isRevoked = proxyWrapper.revoked; // Checks if the proxy is revoked.
Returns​

boolean

true if the proxy is revoked, false otherwise.

Implementation of​

nx.ProxyWrapper.revoked

Methods​

revoke()​

revoke(): void

Defined in: src/utils/ProxyWrapper.ts:69

Revokes the proxy, triggering the revoke function and marking the proxy as revoked. Once revoked, the proxy can no longer be used for its original operations.

Returns​

void

Example​

proxyWrapper.revoke(); // Revokes the proxy and prevents further use.

Implementation of​

nx.ProxyWrapper.revoke