Skip to content

Function: editSave()

editSave<T>(key, updater): boolean

Defined in: save.ts:74

Loads the saved data for the given key, applies an updater function to it, and saves the result back. Does nothing if the key doesn't exist.

Type Parameters

T

T

Parameters

key

string

The key of the saved data to update.

updater

(current) => T

A function that receives the current value and returns the updated value.

Returns

boolean

true if the data was updated successfully, false if the key doesn't exist or saving failed.

Example

ts
// Increment a saved score by 100
facile.editSave('player', (player) => ({ ...player, score: player.score + 100 }));