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

https://github.com/gnlow/lazywrap

Lazy-load async properties
https://github.com/gnlow/lazywrap

async decorators lazy lazy-loading typescript

Last synced: 6 months ago
JSON representation

Lazy-load async properties

Awesome Lists containing this project

README

          

# lazywrap
Lazy-load async properties
## Use
```ts
import {Lw, LwInterface} from "https://denopkg.com/gnlow/lazywrap@main/mod.ts"

class User {
@Lw("load") declare id: Lw
async log() {
console.log("id", await this.id)
}
async load() {
await new Promise(r => setTimeout(r, 1000))
this.id = Math.random()
}
}
const user1 = new User
await user1.log()

interface Music {
id: number
title?: string
}
type LwMusic = LwInterface
// Apply `Lw` to optional properties
/*
{
id: number
title: Lw
}
*/
```