Home Manual Reference Source Repository
public class | source

MultiStorage

Provides short or long term storage via Window.localStorage or Window.sessionStorage.

Constructor Summary

Public Constructor
public

constructor(mainKey: string, session: boolean, serializer: Object)

Initializes MultiStorage.

Member Summary

Public Members
public get

mainKey: *: *

Gets the main key.

public get

serializer: *: *

Gets the serializer.

public get

storageType: *: *

Get storage type.

Method Summary

Public Methods
public

Clears all entries associated with mainKey.

public

Deletes entry filed under key in mainKey hash.

public

Returns the value associated with key in mainKey hash.

public

Returns the entire JSON object stored by mainKey.

public

set(key: string, value: *): Promise<boolean>

Sets a value by the give key in the mainKey hash.

public

setStore(store: *): Promise<boolean>

Sets an entire object to be serialized under mainKey.

Public Constructors

public constructor(mainKey: string, session: boolean, serializer: Object) source

Initializes MultiStorage. First parameter may be an optional object literal hash.

Params:

NameTypeAttributeDescription
mainKey string

Main key to store items for this MultiStorage instance.

session boolean

Boolean to indicate session (short term) storage; default is long term (localStorage).

serializer Object

Instance that conforms to JSON serialization.

Public Members

public get mainKey: *: * source

Gets the main key.

Return:

*

public get serializer: *: * source

Gets the serializer.

Return:

*

public get storageType: *: * source

Get storage type.

Return:

*

Public Methods

public clear(): Promise<boolean> source

Clears all entries associated with mainKey.

Return:

Promise<boolean>

public delete(key: string): Promise<boolean> source

Deletes entry filed under key in mainKey hash.

Params:

NameTypeAttributeDescription
key string

Key to delete.

Return:

Promise<boolean>

public get(key: string): Promise<undefined> source

Returns the value associated with key in mainKey hash.

Params:

NameTypeAttributeDescription
key string

Key to retrieve a value for.

Return:

Promise<undefined>

public getStore(): Promise<undefined> source

Returns the entire JSON object stored by mainKey.

Return:

Promise<undefined>

public set(key: string, value: *): Promise<boolean> source

Sets a value by the give key in the mainKey hash.

Params:

NameTypeAttributeDescription
key string

Key for indexed storage.

value *

Any valid value to serialize.

Return:

Promise<boolean>

public setStore(store: *): Promise<boolean> source

Sets an entire object to be serialized under mainKey.

Params:

NameTypeAttributeDescription
store *

entire object store.

Return:

Promise<boolean>