Allows data to be stored and retrieved between Lens sessions. In other words, data can be saved on device and loaded back in the next time the Lens is opened. Can be accessed with global.persistentStorageSystem.

See the Persistent Storage guide for more information.

// 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
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);
interface PersistentStorageSystem {
    store: GeneralDataStore;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

Methods

Properties

The GeneralDataStore object used to store and retrieve data.

Methods

  • 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