Skip to content
ClassStorage & Replay@public

FlxSave

Port of org.flixel.FlxSave.

Provides namespaced, versioned save slots backed by a replaceable FlxStorageBackend. The default backend is provided by the FlxContext service map (typically LocalStorageBackend).

ts
export declare class FlxSave

Properties

PropertyModifiersTypeDescription
data-Record<string, unknown> | nullUser-facing data object. Read and mutate freely between bind() and close().
name-string | nullSlot name set by bind().

Methods

bind()

ts
bind(name: string, options?: FlxSaveBindOptions): boolean

Bind this save to a named slot.

Reads existing data from the backend. If a version is provided and the stored version differs, the migrate callback transforms the data in-place and the result is flushed back immediately.

Parameters:

ParameterTypeDescription
namestringThe slot name (namespaced automatically by the backend).
optionsFlxSaveBindOptionsOptional version, migration, and backend override.

Returns: boolean

true if data was loaded (even if empty), false on error.

close()

ts
close(): void

Flush and disconnect from the slot.

Returns: void

destroy()

ts
destroy(): void

Release all resources.

Returns: void

erase()

ts
erase(): boolean

Erase all stored data for this slot.

Returns: boolean

eraseAsync()

ts
eraseAsync(): Promise<boolean>

Await erasure for an asynchronous backend.

Returns: Promise<boolean>

flush()

ts
flush(): FlxSaveResult

Persist the current data to the storage backend.

Returns: FlxSaveResult

A typed result indicating success or the failure category.

flushAsync()

ts
flushAsync(): Promise<FlxSaveResult>

Persist data and await durable completion for asynchronous backends. Synchronous backends resolve with the same result as link.

Returns: Promise<FlxSaveResult>

Released under the MIT License.