Skip to content

Add using helper for JS disposable resources#1115

Open
joshamaju wants to merge 9 commits intothefrontside:v4from
joshamaju:using-helper-pr-v4
Open

Add using helper for JS disposable resources#1115
joshamaju wants to merge 9 commits intothefrontside:v4from
joshamaju:using-helper-pr-v4

Conversation

@joshamaju
Copy link
Copy Markdown
Contributor

Motivation

Add an Effection using helper so JavaScript Disposable and AsyncDisposable values can be scope-owned without requiring the native using keyword.

Approach

  • Add lib/using.ts with a using operation that binds disposal to scope teardown.
  • Validate disposers at runtime and fail fast for non-disposable values.
  • Export using from lib/mod.ts.
  • Add test/using.test.ts covering sync and async disposal, teardown on error and halt, async disposal completion, and invalid runtime input.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/thefrontside/effection@1115

commit: d855861

Comment thread lib/using.ts Outdated
Comment thread test/using.test.ts Outdated
Copy link
Copy Markdown
Member

@cowboyd cowboyd left a comment

Choose a reason for hiding this comment

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

Looks good. We don't have to do this with this PR, but we need a place where we are going to explain this. Maybe in the resources section of the guide?

Comment thread lib/using.ts Outdated
Comment thread lib/using.ts Outdated
@joshamaju
Copy link
Copy Markdown
Contributor Author

@cowboyd Please check the tests

@taras taras modified the milestone: v4.1 Feb 26, 2026
@taras taras enabled auto-merge (squash) April 16, 2026 18:18
@taras
Copy link
Copy Markdown
Member

taras commented Apr 16, 2026

@joshamaju can you rebase and verify the signatures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants