Skip to main content

Class: MemoryStateStorage<S>

Store state in memory.

Type Parameters​

S​

S extends IEngineState = IEngineState

Implements​

  • IEngineStateStorage<S>

Constructors​

Constructor​

new MemoryStateStorage<S>(readonlyMode?, state?): MemoryStateStorage<S>

Create a new instance of MemoryStateStorage.

Parameters​

readonlyMode?​

boolean = false

Whether the file is in read-only mode.

state?​

S

The initial state.

Returns​

MemoryStateStorage<S>

Properties​

CLASS_NAME​

readonly static CLASS_NAME: string

Runtime name for the class.

Methods​

load()​

load(engineCore): Promise<S | undefined>

Method for loading the state.

Parameters​

engineCore​

IEngineCore

The engine core to load the state for.

Returns​

Promise<S | undefined>

The state of the engine or undefined if it doesn't exist.

Implementation of​

IEngineStateStorage.load


save()​

save(engineCore, state): Promise<void>

Method for saving the state.

Parameters​

engineCore​

IEngineCore

The engine core to save the state for.

state​

S

The state of the engine to save.

Returns​

Promise<void>

A promise that resolves when the state has been stored in memory.

Implementation of​

IEngineStateStorage.save