Skip to content

Profectus / game/persistence / persistent

Function: persistent() ​

persistent<T>(defaultValue, checkNaN): Persistent<T>

Create a persistent ref, which can be saved and loaded. All (non-deleted) persistent refs must be included somewhere within the layer object returned by that layer's options func.

Type Parameters ​

• T extends State

Parameters ​

defaultValue ​

The value the persistent ref should start at on fresh saves or when reset.

T | Ref<T, T>

checkNaN ​

boolean = true

Whether or not to check this ref for being NaN on set. Only use on refs that should always be DecimalSources.

Returns ​

Persistent<T>

Defined in ​

profectus/src/game/persistence.ts:131