oracular / serialize
Function: serialize()
ts
function serialize(state): string;Defined in: serialize.ts:33
The state as a JSON string, for the host app to persist wherever it likes. The state is plain data, so this is JSON.stringify after a shape check. The output never contains event props.
Parameters
| Parameter | Type | Description |
|---|---|---|
state | EngineState | The state to persist. |
Returns
string
A JSON string that deserialize restores losslessly.
Throws
TypeError when state is not an engine state.
Example
ts
localStorage.setItem('oracular', serialize(state));