Skip to Content
defold-typescript libraries
megalanthusdefold-gamepush

megalanthus/defold-gamepush/gamepush.core.storage

GamePush key-value storage: context and global values, with their events.

  • GitHub: megalanthus/defold-gamepush — pinned to v1.4.1
    1. Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as core_storage from "gamepush.core.storage"

Functions

set_storage(storage_type: string)

Chooses the context storage. Raises unless storage_type is a string.

Parameters

  • storage_type: string — "platform" or "local".

set(key: string, value: unknown, callback?: (result: unknown) => void)

Writes a value to the context storage.

Parameters

  • key: string — The key.
  • value: unknown — The value, encoded as JSON.
  • callback?: (result: unknown) => void — Receives the result.

get(key: string, callback?: (result: unknown) => void): unknown

Reads a value from the context storage. Returns it when callback is nil, and returns nil and hands it to callback otherwise.

Parameters

  • key: string — The key.
  • callback?: (result: unknown) => void — Receives the value.

Returns

  • unknown

set_global(key: string, value: unknown, callback?: (result: unknown) => void)

Writes a value to the global storage.

Parameters

  • key: string — The key.
  • value: unknown — The value, encoded as JSON.
  • callback?: (result: unknown) => void — Receives the result.

get_global(key: string, callback?: (result: unknown) => void): unknown

Reads a value from the global storage. Returns it when callback is nil, and returns nil and hands it to callback otherwise.

Parameters

  • key: string — The key.
  • callback?: (result: unknown) => void — Receives the value.

Returns

  • unknown

Variables

callbacks: StorageCallbacks

The storage event handlers.

Types

StorageCallbacks

StorageCallbacks.set?: (result: unknown) => void

A value was written to the context storage.

StorageCallbacks.get?: (result: unknown) => void

A value was read from the context storage.

StorageCallbacks.set_global?: (result: unknown) => void

A value was written to the global storage.

StorageCallbacks.get_global?: (result: unknown) => void

A value was read from the global storage.

On this page