Resource
Resource<
E,A> =object
Defined in: Core/Resource.ts:34
A Resource pairs an async acquisition step with a guaranteed cleanup step.
Use it whenever something must be explicitly closed, released, or torn down after you are done with it — database connections, file handles, locks, temporary directories, or any object with a lifecycle.
The key guarantee: release always runs after Resource.use, even when
the work function returns an error. If acquire itself fails, release is
skipped — there is nothing to clean up.
Build a Resource with Resource.make or Resource.fromTask, then run it
with Resource.use.
Example
Section titled “Example”Type Parameters
Section titled “Type Parameters”E
A
Properties
Section titled “Properties”acquire
Section titled “acquire”
readonlyacquire:TaskResult<E,A>
Defined in: Core/Resource.ts:35
release()
Section titled “release()”
readonlyrelease: (a) =>Task<void>
Defined in: Core/Resource.ts:36
Parameters
Section titled “Parameters”A
Returns
Section titled “Returns”Task<void>