Class for storing and retrieving data based on keys. Used by PersistentStorageSystem. For more information, see the Persistent Storage guide.

// Get the data store from PersistentStorageSystem
var store = global.persistentStorageSystem.store;

// Load score from previous Lens session. Defaults to 0 if data isn't found for this key
var score = store.getFloat("totalScore");
print("loaded score: " + score);

function increaseScore() {
// Increase score, then write it to the data store
score += 1;
store.putFloat("totalScore", score);
print("new score: " + score);
}

// Increase score on tap event
script.createEvent("TapEvent").bind(increaseScore);
// Check Launch Params for a certain string value
var stringParamName = "testString";
if (global.launchParams && global.launchParams.has(stringParamName)) {
var myString = global.launchParams.getString(stringParamName);
}
interface GeneralDataStore {
    onStoreFull: (() => void);
    clear(): void;
    getAllKeys(): string[];
    getBool(key: string): boolean;
    getBoolArray(key: string): boolean[];
    getDouble(key: string): number;
    getFloat(key: string): number;
    getFloat32Array(key: string): Float32Array;
    getFloat64Array(key: string): any;
    getFloatArray(key: string): number[];
    getInt(key: string): number;
    getInt16Array(key: string): any;
    getInt32Array(key: string): any;
    getInt8Array(key: string): any;
    getIntArray(key: string): number[];
    getMat2(key: string): mat2;
    getMat2Array(key: string): mat2[];
    getMat3(key: string): mat3;
    getMat3Array(key: string): mat3[];
    getMat4(key: string): mat4;
    getMat4Array(key: string): mat4[];
    getMaxSizeInBytes(): number;
    getQuat(key: string): quat;
    getQuatArray(key: string): quat[];
    getSizeInBytes(): number;
    getString(key: string): string;
    getStringArray(key: string): string[];
    getTypeName(): string;
    getUint16Array(key: string): Uint16Array;
    getUint32Array(key: string): Uint32Array;
    getUint8Array(key: string): Uint8Array;
    getVec2(key: string): vec2;
    getVec2Array(key: string): vec2[];
    getVec3(key: string): vec3;
    getVec3Array(key: string): vec3[];
    getVec4(key: string): vec4;
    getVec4Array(key: string): vec4[];
    has(key: string): boolean;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    putBool(key: string, value: boolean): void;
    putBoolArray(key: string, value: boolean[]): void;
    putDouble(key: string, value: number): void;
    putFloat(key: string, value: number): void;
    putFloat32Array(key: string, value: Float32Array): void;
    putFloat64Array(key: string, value: any): void;
    putFloatArray(key: string, value: number[]): void;
    putInt(key: string, value: number): void;
    putInt16Array(key: string, value: any): void;
    putInt32Array(key: string, value: any): void;
    putInt8Array(key: string, value: any): void;
    putIntArray(key: string, value: number[]): void;
    putMat2(key: string, value: mat2): void;
    putMat2Array(key: string, value: mat2[]): void;
    putMat3(key: string, value: mat3): void;
    putMat3Array(key: string, value: mat3[]): void;
    putMat4(key: string, value: mat4): void;
    putMat4Array(key: string, value: mat4[]): void;
    putQuat(key: string, value: quat): void;
    putQuatArray(key: string, value: quat[]): void;
    putString(key: string, value: string): void;
    putStringArray(key: string, value: string[]): void;
    putUint16Array(key: string, value: Uint16Array): void;
    putUint32Array(key: string, value: Uint32Array): void;
    putUint8Array(key: string, value: Uint8Array): void;
    putVec2(key: string, value: vec2): void;
    putVec2Array(key: string, value: vec2[]): void;
    putVec3(key: string, value: vec3): void;
    putVec3Array(key: string, value: vec3[]): void;
    putVec4(key: string, value: vec4): void;
    putVec4Array(key: string, value: vec4[]): void;
    remove(key: string): void;
}

Hierarchy (view full)

Properties

onStoreFull: (() => void)

Callback function that gets called when the allowed storage limit has been passed. The store won't be saved if it is full, so if this is called make sure to remove data until back under the limit.

Methods

  • Clears all data stored in the General Data Store.

    Returns void

  • Returns an array with all the keys in the store.

    Returns string[]

  • Returns a boolean value stored under the given key, or false if none exists.

    Parameters

    • key: string

    Returns boolean

  • Returns a boolean array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns boolean[]

  • Returns a double precision floating point number stored under the given key, or 0 if none exists.

    Parameters

    • key: string

    Returns number

  • Returns a floating point value stored under the given key, or 0 if none exists.

    Parameters

    • key: string

    Returns number

  • Parameters

    • key: string

    Returns Float32Array

  • Parameters

    • key: string

    Returns any

  • Returns a floating point array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns number[]

  • Returns an integer number stored under the given key, or 0 if none exists.

    Parameters

    • key: string

    Returns number

  • Parameters

    • key: string

    Returns any

  • Parameters

    • key: string

    Returns any

  • Parameters

    • key: string

    Returns any

  • Returns an integer array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns number[]

  • Returns a mat2 value stored under the given key, or a default mat2 if none exists.

    Parameters

    • key: string

    Returns mat2

  • Returns a mat2 array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns mat2[]

  • Stores a mat3 value under the given key.

    Parameters

    • key: string

    Returns mat3

  • Returns a mat3 array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns mat3[]

  • Returns a mat4 value stored under the given key, or a default mat4 if none exists.

    Parameters

    • key: string

    Returns mat4

  • Returns a mat4 array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns mat4[]

  • Returns the maximum total size allowed, in bytes, of all data stored in this General Data Store.

    Returns number

  • Returns a quat value stored under the given key, or a default quat if none exists.

    Parameters

    • key: string

    Returns quat

  • Returns a quat array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns quat[]

  • If onStoreFull has been set, this method returns the current total size, in bytes, of all data stored in this General Data Store. Otherwise, 0 is returned.

    Returns number

  • Returns a string value stored under the given key, or empty string if none exists.

    Parameters

    • key: string

    Returns string

  • Returns a string array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns string[]

  • Parameters

    • key: string

    Returns Uint16Array

  • Parameters

    • key: string

    Returns Uint32Array

  • Parameters

    • key: string

    Returns Uint8Array

  • Returns a vec2 value stored under the given key, or a default vec2 if none exists.

    Parameters

    • key: string

    Returns vec2

  • Returns a vec2 array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns vec2[]

  • Returns a vec3 value stored under the given key, or a default vec3 if none exists.

    Parameters

    • key: string

    Returns vec3

  • Returns a vec3 array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns vec3[]

  • Returns a vec4 value stored under the given key, or a default vec4 if none exists.

    Parameters

    • key: string

    Returns vec4

  • Returns a vec4 array being stored under the given key, or an empty array if none exists.

    Parameters

    • key: string

    Returns vec4[]

  • Returns true if a value is being stored under the given key.

    Parameters

    • key: string

    Returns boolean

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Stores a boolean value under the given key.

    Parameters

    • key: string
    • value: boolean

    Returns void

  • Stores a boolean array under the given key.

    Parameters

    • key: string
    • value: boolean[]

    Returns void

  • Stores a double precision floating point number under the given key.

    Parameters

    • key: string
    • value: number

    Returns void

  • Stores a floating point value under the given key.

    Parameters

    • key: string
    • value: number

    Returns void

  • Parameters

    • key: string
    • value: Float32Array

    Returns void

  • Parameters

    • key: string
    • value: any

    Returns void

  • Stores a floating point array under the given key.

    Parameters

    • key: string
    • value: number[]

    Returns void

  • Stores an integer number value under the given key.

    Parameters

    • key: string
    • value: number

    Returns void

  • Parameters

    • key: string
    • value: any

    Returns void

  • Parameters

    • key: string
    • value: any

    Returns void

  • Parameters

    • key: string
    • value: any

    Returns void

  • Stores an integer array under the given key.

    Parameters

    • key: string
    • value: number[]

    Returns void

  • Stores a mat2 value under the given key.

    Parameters

    • key: string
    • value: mat2

    Returns void

  • Stores a mat2 array under the given key.

    Parameters

    • key: string
    • value: mat2[]

    Returns void

  • Stores a mat3 value under the given key.

    Parameters

    • key: string
    • value: mat3

    Returns void

  • Stores a mat3 array under the given key.

    Parameters

    • key: string
    • value: mat3[]

    Returns void

  • Stores a mat4 value under the given key.

    Parameters

    • key: string
    • value: mat4

    Returns void

  • Stores a mat4 array under the given key.

    Parameters

    • key: string
    • value: mat4[]

    Returns void

  • Stores a quat value under the given key.

    Parameters

    • key: string
    • value: quat

    Returns void

  • Stores a quat array under the given key.

    Parameters

    • key: string
    • value: quat[]

    Returns void

  • Stores a string value under the given key.

    Parameters

    • key: string
    • value: string

    Returns void

  • Stores a string array under the given key.

    Parameters

    • key: string
    • value: string[]

    Returns void

  • Parameters

    • key: string
    • value: Uint16Array

    Returns void

  • Parameters

    • key: string
    • value: Uint32Array

    Returns void

  • Parameters

    • key: string
    • value: Uint8Array

    Returns void

  • Stores a vec2 value under the given key.

    Parameters

    • key: string
    • value: vec2

    Returns void

  • Stores a vec2 array under the given key.

    Parameters

    • key: string
    • value: vec2[]

    Returns void

  • Stores a vec3 value under the given key.

    Parameters

    • key: string
    • value: vec3

    Returns void

  • Stores a vec3 array under the given key.

    Parameters

    • key: string
    • value: vec3[]

    Returns void

  • Stores a vec4 value under the given key.

    Parameters

    • key: string
    • value: vec4

    Returns void

  • Stores a vec4 array under the given key.

    Parameters

    • key: string
    • value: vec4[]

    Returns void

  • Removes the value being stored under the given key. If no value exists under the key, nothing will happen.

    Parameters

    • key: string

    Returns void