---
url: /api/kiln/classes/SaveSlots.md
---
[Kiln API](../../index.md) / [kiln](../index.md) / SaveSlots

# Class: SaveSlots

Save slots: `res.mut(Saves).save('slot1')` writes now; `.load('slot1')` applies at the start of
the next frame and emits `Loaded`. Also `has`, `delete`, `slots()`. What is saved comes from
`savePlugin({ resources, traits })`.

## Constructors

### Constructor

```ts
new SaveSlots(app, opts): SaveSlots;
```

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `app` | [`App`](App.md) |
| `opts` | { `resources`: [`Resource`](../interfaces/Resource.md)<`any`>\[]; `traits`: `Trait`\[]; `key`: `string`; `storage`: [`SaveStorage`](../interfaces/SaveStorage.md); } |
| `opts.resources` | [`Resource`](../interfaces/Resource.md)<`any`>\[] |
| `opts.traits` | `Trait`\[] |
| `opts.key` | `string` |
| `opts.storage` | [`SaveStorage`](../interfaces/SaveStorage.md) |

#### Returns

`SaveSlots`

## Properties

### pendingLoad

```ts
pendingLoad: string | null = null;
```

A load requested this frame, applied at the next frame start.

## Methods

### save()

```ts
save(slot?): string;
```

Writes the slot now and emits Saved. Returns the JSON written.

#### Parameters

| Parameter | Type | Default value |
| ------ | ------ | ------ |
| `slot` | `string` | `'auto'` |

#### Returns

`string`

***

### load()

```ts
load(slot?): boolean;
```

Loads the slot at the start of the next frame. Returns false (and does nothing) if it doesn't exist.

#### Parameters

| Parameter | Type | Default value |
| ------ | ------ | ------ |
| `slot` | `string` | `'auto'` |

#### Returns

`boolean`

***

### has()

```ts
has(slot?): boolean;
```

#### Parameters

| Parameter | Type | Default value |
| ------ | ------ | ------ |
| `slot` | `string` | `'auto'` |

#### Returns

`boolean`

***

### delete()

```ts
delete(slot?): void;
```

#### Parameters

| Parameter | Type | Default value |
| ------ | ------ | ------ |
| `slot` | `string` | `'auto'` |

#### Returns

`void`

***

### slots()

```ts
slots(): string[];
```

Slot names that exist, sorted.

#### Returns

`string`\[]

***

### toJSON()

```ts
toJSON(): object;
```

#### Returns

`object`

##### slots

```ts
slots: string[];
```

##### pendingLoad

```ts
pendingLoad: string | null;
```
