-
-
Notifications
You must be signed in to change notification settings - Fork 562
datner/acquire disposable #6209
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
base: next-minor
Are you sure you want to change the base?
Changes from all commits
8b7feda
8d28ff3
e3bca39
27ba280
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "effect": minor | ||
| --- | ||
|
|
||
| add `Effect.acquireDisposable` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1691,6 +1691,17 @@ export const acquireRelease: { | |
| core.tap(acquire, (a) => addFinalizer((exit) => release(a, exit))) | ||
| )) | ||
|
|
||
| /* @internal */ | ||
| export const acquireDisposable: { | ||
| <A extends AsyncDisposable | Disposable, E, R>( | ||
| acquire: Effect.Effect<A, E, R> | ||
| ): Effect.Effect<A, E, R | Scope.Scope> | ||
| } = (acquire) => | ||
| acquireRelease(acquire, (resource) => | ||
| Predicate.hasProperty(resource, Symbol.asyncDispose) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi! I just had a thought.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe the assumption is that if there is an async one the sync doesn't wait?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it has both dispose symbols, are both invoked? In which order? |
||
| ? internalEffect.promise(() => resource[Symbol.asyncDispose]()) | ||
| : core.sync(() => resource[Symbol.dispose]())) | ||
|
|
||
| /* @internal */ | ||
| export const acquireReleaseInterruptible: { | ||
| <X, R2>( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk what to put here