WebStorage

ol-ishare/store. WebStorage

Store items with the Web Storage API

By default will attempt to use Local Storage and fall back to Session Storage. If neither can be used, throws an error.

Storage keys will gain a prefix that includes the URL path to diffentiate the saved settings in one application from those in another but under the same domain. Note: this means that pages stored by a default page loaded from the URL without the page name will have different keys to those when the page is loaded with its full path.

Constructor

new WebStorage(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>

Settings for working with Web Storage

Properties
Name Type Attributes Default Description
prefix String <optional>
'oli-store/[path]'

Sets the prefix for all keys - change to allow applications in the same domain to use the same items.

useSession Boolean <optional>
false

Whether to only try to use Session Storage

Extends

Members

type :'local'|'session'|undefined

WebStorage type in use

Type:
  • 'local' | 'session' | undefined

Methods

(abstract) put(dict) → {Promise}

Overrides:

Put items in storage

Parameters:
Name Type Description
dict Object

Items to store, keys/property names must be strings. Values must be serializable to strings.

Returns:

Resolves to the keys of values that were successfully stored.

Type
Promise

(abstract) fetch(keys) → {Promise}

Overrides:

Fetch items from storage

Parameters:
Name Type Description
keys Array.<String>

Names of items to fetch from storage.

Returns:

Resolves to an object with properties for each valid key, and the stored item with that name as the value.

Type
Promise

(abstract) discard(keys) → {Promise}

Overrides:

Discard items in storage

Parameters:
Name Type Description
keys Array.<String>

Names of items to discard.

Returns:

Resolves to an array of names of items that were successfully deleted.

Type
Promise