API Reference
Namespaces
Classes
Events
Global
Externals

Class: NameValueStore

CIQ. NameValueStore


new NameValueStore()

Base class for interacting with a name/value store.

This base class saves to local storage, but you can create your own function overrides for remote storage as long as you maintain the same function signatures and callback requirements.

See WebComponents.Views for an implementation example.

Methods


get(field, cb)

Retrieves a value from the name/value store.

Parameters:
Name Type Description
field string

The field for which the value is retrieved.

cb CIQ.NameValueStore~getCallback

A callback function called after the retrieval operation has been completed. Two arguments are provided to the callback function. The first argument indicates the success or failure of the operation; the second argument is the value returned by the operation.

Since:
Example
nameValueStore.get("myfield", function(err, data) {
    if (err) {
        // Do something with the error.
    } else {
        // Do something with the retrieved data.
    }
});

remove(field [, cb])

Removes a field from the name/value store.

Parameters:
Name Type Argument Description
field string

The field to remove.

cb CIQ.NameValueStore~updateCallback <optional>

A callback function called after the storage operation has been completed. A single argument, which indicates success or failure of the operation, is provided to the callback function.

Since:
Example
nameValueStore.remove("myfield", function(err) {
    if (err) {
        // Do something with the error.
    } else {
        // Do something after the field has been removed.
    }
});

set(field, value [, cb])

Stores a value in the name/value store.

Parameters:
Name Type Argument Description
field string

The name under which the value is stored.

value string | object

The value to store.

cb CIQ.NameValueStore~updateCallback <optional>

A callback function called after the storage operation has been completed. A single argument, which indicates success or failure of the operation, is provided to the callback function.

Since:
Example
nameValueStore.set("myfield", "myValue", function(err) {
    if (err) {
        // Do something with the error.
    } else {
        // Do something after the data has been stored.
    }
});

Type Definitions


getCallback(error, response)

A function called after a retrieval operation on the name/value store has been completed.

Parameters:
Name Type Description
error object | string

An error object or error code if data retrieval failed; null if data retrieval was successful.

response object | string

The data retrieved from storage or null if retrieval failed.

Since:
  • 8.2.0


updateCallback(error)

A function called after an update of the name/value store has been completed.

Parameters:
Name Type Description
error object | string

An error object or error code if the storage update failed; null if the update was successful.

Since:
  • 8.2.0