Skip to content

1681-engine / index / Autosaver

Class: Autosaver ​

Defined in: src/save/Autosaver.ts:31

Saves a slot when the game says something changed, but never more often than intervalMs: a burst of changes (every pickup in a fight) becomes one save now and one trailing save at the end of the interval with the newest state. snapshot is read when the save happens, not when it was asked for, so the trailing save is never stale.

Constructors ​

Constructor ​

ts
new Autosaver(
   store, 
   slot, 
   snapshot, 
   options?
): Autosaver;

Defined in: src/save/Autosaver.ts:40

Parameters ​

ParameterType
storeSaveStore
slotstring
snapshot() => unknown
optionsAutosaverOptions

Returns ​

Autosaver

Methods ​

dispose() ​

ts
dispose(): void;

Defined in: src/save/Autosaver.ts:74

Stops autosaving; a pending trailing save is dropped (call flush first to keep it).

Returns ​

void


flush() ​

ts
flush(): Promise<void>;

Defined in: src/save/Autosaver.ts:64

Saves now if anything is waiting (leaving the game, a scene change); resolves when it is written.

Returns ​

Promise<void>


request() ​

ts
request(): void;

Defined in: src/save/Autosaver.ts:51

Something worth saving changed.

Returns ​

void

Released under the MIT License.