kango.storage

Summary

Name Description
getItem Returns stored item by name
setItem Saves named item
removeItem Removes item by name
getKeys Returns array of item names
clear Delete all the items
note:You can use this module in content scripts.

Methods

getItem

kango.storage.getItem(name)

Returns item stored by name or null if item does not exist.

Arguments:
  • name (string) – Item name
Return type:

variant

Example:

var homeUrl = kango.storage.getItem('home_url');
kango.console.log('stored value for homeUrl is ' + homeUrl);

setItem

kango.storage.setItem(name, value)

Saves an item with specified name.

Arguments:
  • name (string) – Item name
  • value (variant) – Data to be saved

Example:

kango.storage.setItem('height', 176);
var storedHeight = kango.storage.getItem('height');
kango.console.log('stored height is ' + storedHeight );

removeItem

kango.storage.removeItem(name)

Removes item with specified name.

Arguments:
  • name (string) – Item name

Example:

kango.storage.setItem('height', 176);

var storedHeight = kango.storage.getItem('height');
kango.console.log('stored height is ' + storedHeight );

kango.storage.removeItem('height');

storedHeight = kango.storage.getItem('height'); // null

getKeys

kango.storage.getKeys()

Returns array of item names.

Returns:array of item names
Return type:Array of strings

Example:

var keys = kango.storage.getKeys();
kango.console.log(keys.toString());

clear

kango.storage.clear()

Removes all the items from storage.

Example:

kango.storage.clear();