API Reference

proxy-registry

API entries in this module: 2

Current proxy-registry implementation

IProxyRegistry resolves to ProxyRegistry as a shared singleton service. It stores target/proxy pairs in memory.

register(target, proxy) adds or replaces a mapping. getProxy(target) returns the proxy for a target.

getProxyTarget(proxy) returns the original target for a proxy. isProxy(value) checks whether a value is currently registered as a proxy. unregister(target) removes a mapping.

This registry is memory-only (not persisted). Core services use it to move between wrapped and unwrapped references consistently (for example in deep-clone flows).

Example: use IProxyRegistry

import {
  InjectionContainer,
  RsXCoreInjectionTokens,
  RsXCoreModule,
  type IProxyRegistry,
} from '@rs-x/core';

await InjectionContainer.load(RsXCoreModule);

const proxyRegistry = InjectionContainer.get<IProxyRegistry>(
  RsXCoreInjectionTokens.IProxyRegistry,
);

const target = { id: 1 };
const proxy = new Proxy(target, {});

proxyRegistry.register(target, proxy);

const resolvedProxy = proxyRegistry.getProxy(target);
const resolvedTarget = proxyRegistry.getProxyTarget(proxy);

console.log(resolvedProxy === proxy); // true