Skip to content
module@warp-drive/core/reactive

Function checkout() ​

ts
function checkout<T>(resource: unknown): Promise<T & ReactiveResource>;

Defined in: warp-drive-packages/core/src/reactive/-private/record.ts:761

Checkout an immutable resource for editing.

ReactiveResources are not editable by default. This method creates an editable copy of the resource.

This returns a promise which resolves with the editable version of the resource.

ts
import { checkout } from '@warp-drive/core/reactive';

const immutable = store.peekRecord('user', '1');
const editable = await checkout(immutable);

Edits to editable resources will be automatically committed if a new payload from the cache matches their existing value.

Type Parameters ​

T ​

T

Parameters ​

resource ​

unknown

Returns ​

Promise<T & ReactiveResource>

a promise that resolves to the editable resource

Throws ​

if the resource is already editable or if resource is an embedded object

Released under the MIT License.