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- Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as core_storage from "gamepush.core.storage"
- Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged
Functions
set_storage(storage_type: string)set(key: string, value: unknown, callback?: (result: unknown) => void)get(key: string, callback?: (result: unknown) => void): unknownset_global(key: string, value: unknown, callback?: (result: unknown) => void)get_global(key: string, callback?: (result: unknown) => void): unknown
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.