Packaging · class
FileStore
The engine's persistence seam, backed by a file the shell owns.
Explained in Packaging an application.
class FileStore implements KeyValueStoreimport { 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)| Parameter | Type | Description |
|---|---|---|
bridge | DriftHostBridge |
Methods
read
read(key: string): string | null| Parameter | Type | Description |
|---|---|---|
key | string |
write
write(key: string, value: string): void| Parameter | Type | Description |
|---|---|---|
key | string | |
value | string |
remove
remove(key: string): void| Parameter | Type | Description |
|---|---|---|
key | string |