Skip to main content

Function: useWriteSaves()

useWriteSaves(): (saves, options?) => Promise<WriteSavesResult>

Defined in: packages/core/src/saves/hooks/useWriteSaves.ts:38

React hook that writes whole save records into the database.

Returns​

Callback that writes save records and reports how many landed

(saves, options?): Promise<WriteSavesResult>

Parameters​

saves​

GameSave[]

options?​

mode?​

WriteSavesMode

Returns​

Promise<WriteSavesResult>

Remarks​

Records keep the timestamp and version they carry, so saves restored from a file stay in the order the player knew them by. In replace mode the wipe and the writes share a transaction: nothing is destroyed unless the whole write succeeds.

Example​

const writeSaves = useWriteSaves();
await writeSaves(saves, { mode: 'merge' });