Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Symbol.asyncDispose #95

Merged
merged 1 commit into from
Dec 27, 2024
Merged

Implement Symbol.asyncDispose #95

merged 1 commit into from
Dec 27, 2024

Conversation

vweevers
Copy link
Member

Per proposal-explicit-resource-management which in TypeScript (5.2) allows you to skip calling .close():

await db.put('example', 'before')
await using snapshot = db.snapshot()
await db.put('example', 'after')
await db.get('example', { snapshot })) // Returns 'before'

Works on databases, iterators, snapshots and batches.

Per https://github.com/tc39/proposal-explicit-resource-management
which in TypeScript (5.2) allows you to skip calling `.close()`:

```ts
await db.put('example', 'before')
await using snapshot = db.snapshot()
await db.put('example', 'after')
await db.get('example', { snapshot })) // Returns 'before'
```

Works on databases, iterators, snapshots and batches.

Category: addition
@vweevers vweevers added enhancement New feature or request semver-minor New features that are backward compatible labels Dec 27, 2024
@vweevers vweevers merged commit eedeed9 into main Dec 27, 2024
10 checks passed
@vweevers vweevers deleted the async-dispose branch December 27, 2024 18:39

```ts
await db.put('example', 'before')
await using snapshot = db.snapshot()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome to know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver-minor New features that are backward compatible
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants