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 ​
new Autosaver(
store,
slot,
snapshot,
options?
): Autosaver;Defined in: src/save/Autosaver.ts:40
Parameters ​
| Parameter | Type |
|---|---|
store | SaveStore |
slot | string |
snapshot | () => unknown |
options | AutosaverOptions |
Returns ​
Autosaver
Methods ​
dispose() ​
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() ​
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() ​
request(): void;Defined in: src/save/Autosaver.ts:51
Something worth saving changed.
Returns ​
void