An open API service indexing awesome lists of open source software.

https://github.com/tripolskypetr/di-lazy

Lazy instantiation of the class based on the first access to its reference
https://github.com/tripolskypetr/di-lazy

dependency-injection grpc lazy-loading oop optimization optimization-algorithms performance

Last synced: 4 months ago
JSON representation

Lazy instantiation of the class based on the first access to its reference

Awesome Lists containing this project

README

          

# di-lazy

> Lazy instantiation of the class based on the first access to its reference

## Usage

```tsx

const LazyClass = lazy(class {
constructor(...args: number[]) {
console.log("CTOR", { args })
}
test = () => console.log("test");
}, "test");

const lazyInstance = new LazyClass(1, 2, 3);

console.log("Instance created");

lazyInstance.test(); // CTOR { args: [ 1, 2, 3 ] }

console.log("Method executed")

```