API reference@evolu/commonResource › ResourceRef

Defined in: packages/common/src/Resource.ts:93

Resource reference.

A MutexRef-like reference for resources. ResourceRef controls the resource lifecycle.

Callers get the current resource as BorrowedResource to ensure only the ResourceRef can dispose it.

Setting a new resource first disposes the current one and then sets the next. Calling abort on the returned Fiber does not roll that change back once it has started. The create Task must not fail. If it could fail, the current resource would be disposed without the next resource installed.

Extends

Methods

[asyncDispose]()

asyncDispose: PromiseLike<void>;

Defined in: node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.esnext.disposable.d.ts:40

Inherited from

AsyncDisposable.[asyncDispose]

Properties

get

readonly get: Task<BorrowedResource<T>, never, D>;

Defined in: packages/common/src/Resource.ts:98

Returns the current resource.


set

readonly set: (create: Task<T, never, D>) => Task<void, never, D>;

Defined in: packages/common/src/Resource.ts:106

Disposes the current resource and then creates and sets the next.

Once started, this operation runs to completion even if the caller aborts its Fiber. Always await the result instead of treating abort as rollback.