Skip to content
EN

reearth.data

Last updated

The reearth.data namespace provides methods to manage client-side storage in reearth plugins. It allows asynchronous retrieval, updating, and deletion of data, as well as managing storage keys and clearing the entire store. This namespace is useful for persisting user preferences, session data, or temporary settings.

The clientStorage offers an interface for managing a lightweight, asynchronous key-value storage system. It provides several methods for interacting with the plugin’s client-side storage, including reading, writing, and deleting data.

Stores a key-value pair in the storage.

reearth.data.clientStorage.setAsync(key: string, value: unknown): Promise<void>

Type string

The key to associate with the value.

Type unknown

The value to store.

Type Promise<void>

A promise that resolves when the key-value pair is saved.

Retrieves the value associated with a specific key.

reearth.data.clientStorage.getAsync(key: string): Promise<unknown>

Type string

The key of the value to retrieve.

Type Promise<unknown>

A promise that resolves with the value associated with the key, or undefined if the key doesn’t exist.

Retrieves all keys stored in the client storage.

reearth.data.clientStorage.keysAsync(): Promise<string[]>

Type Promise<string[]>

A promise that resolves with an array of strings, each representing a key.

Removes a key-value pair from the storage.

reearth.data.clientStorage.deleteAsync(key: string): Promise<void>

Type string

The key of the value to delete.

Type Promise<void>

A promise that resolves when the key-value pair is deleted.

Clears all data from the client storage.

reearth.data.clientStorage.dropStoreAsync(): Promise<void>

Type Promise<void>

A promise that resolves when the storage is cleared.