[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Resource](https://evolu.dev/docs/api-reference/common/Resource) › ResourceRef

Defined in: [packages/common/src/Resource.ts:93](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Resource.ts#L93)

[Resource](https://evolu.dev/docs/api-reference/common/Resource/type-aliases/Resource) reference.

A [MutexRef](https://evolu.dev/docs/api-reference/common/Task/interfaces/MutexRef)-like reference for resources. `ResourceRef` controls the
resource lifecycle.

Callers get the current resource as [BorrowedResource](https://evolu.dev/docs/api-reference/common/Resource/type-aliases/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

- [`AsyncDisposable`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-management)

## Methods

<a id="asyncdispose"></a>

### \[asyncDispose\]()

```ts
asyncDispose: PromiseLike<void>;
```

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

#### Inherited from

```ts
AsyncDisposable.[asyncDispose]
```

## Properties

<a id="get"></a>

### get

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

Defined in: [packages/common/src/Resource.ts:98](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Resource.ts#L98)

Returns the current resource.

---

<a id="set"></a>

### set

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

Defined in: [packages/common/src/Resource.ts:106](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Resource.ts#L106)

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.