@tmlmobilidade/utils
Version:
A collection of utility functions and helpers for the TML Mobilidade Go monorepo, providing common functionality for batching operations, caching, HTTP requests, object manipulation, permissions, and more.
12 lines (11 loc) • 735 B
TypeScript
/**
* Creates a recursive async proxy for a singleton class that delays method and property access until the instance is initialized.
* Supports nested property chains like `await proxy.core.agencies.findById(id)` by recursively wrapping each property access
* in a new proxy, resolving the full path only when the chain is invoked (called as a function or awaited).
*
* @param cls - A class with a static `getInstance` method that returns a promise resolving to the class instance.
* @returns A proxy object that intercepts property access and method calls, ensuring the instance is initialized before resolving.
*/
export declare function asyncSingletonProxy<T extends object>(cls: {
getInstance: () => Promise<T>;
}): T;