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 override your own for remote storage, as long as you maintain the same function signatures and call back requirements.

See CIQ.UI.ViewsMenu for implementatin example.

Methods


get(field, cb)

Get a value from the name value store

Parameters:
Name Type Description
field string

The field to fetch

cb function

Callback. First field is error or null. Second field is the result.

Example
nameValueStore.get("myfield", function(err,data){
   if(!err){
       // do something with data
       if(cb) cb(errorCode, yourViewObject);
   }
});

remove(field, cb)

Remove a field from the name value store

Parameters:
Name Type Description
field string

The field to remove

cb function

Callback

Example
nameValueStore.remove("myfield", function(){
       // do something after data has been removed
       if(cb) cb(errorCode);
   }
});

set(field, value, cb)

Set a value to the name value store

Parameters:
Name Type Description
field string

The field to fetch

value string

The value to store

cb function

Callback

Example
nameValueStore.set("myfield", "myValue", function(){
       // do something after data has been saved
       if(cb) cb(errorCode);
   }
});