Packaging · class

FileStore

The engine's persistence seam, backed by a file the shell owns.

Explained in Packaging an application.

class FileStore implements KeyValueStore
import { FileStore } from '@driftengine/package';

In depth

Reads come from a snapshot taken before the window opened and from this session's own writes; writes go to the main process and do not block. That is precisely the arrangement KeyValueStore's own doc comment prescribes for an asynchronous backend — hydrate a cache first, make write fire-and-forget — and it is why the interface never needed widening for this.

What this costs: a write that fails on disk is not reported here. The main process logs it; the game continues with the value in memory, which is the same degradation BrowserStore makes when localStorage throws. A preference is never worth failing a boot for.

Constructor

new

constructor(bridge: DriftHostBridge)
ParameterTypeDescription
bridgeDriftHostBridge

Methods

read

read(key: string): string | null
ParameterTypeDescription
keystring

write

write(key: string, value: string): void
ParameterTypeDescription
keystring
valuestring

remove

remove(key: string): void
ParameterTypeDescription
keystring