Class: Persist

Persist

new Persist()

The persistent storage class handles loading and saving data to browser storage.
Source:

Members

addStep

Adds an encode/decode step to the persistent storage system so that you can add custom functionality.
Source:

localforage

The local forage library.
Source:

Methods

(private) _decode(val, meta, finished)

Takes encoded data and decodes it for use as JS native objects and arrays.
Parameters:
Name Type Description
val String The currently encoded string data.
meta Object Meta data object that can be used to pass back useful supplementary data.
finished function The callback method to call when decoding is completed.
Source:

(private) _encode(val, meta, finished)

Takes native JS data and encodes it for for storage as a string.
Parameters:
Name Type Description
val Object The current un-encoded data.
meta Object Meta data object that can be used to pass back useful supplementary data.
finished function The callback method to call when encoding is completed.
Source:

decode(val, finished)

Starts a decode waterfall process.
Parameters:
Name Type Description
val * The data to be decoded.
finished function The callback to pass final data to.
Source:

driver(val) → {*}

Gets / sets the driver used when persisting data.
Parameters:
Name Type Description
val String Specify the driver type (LOCALSTORAGE, WEBSQL or INDEXEDDB)
Source:
Returns:
Type
*

drop(key, callbackopt)

Deletes data in persistent storage stored under the passed key.
Parameters:
Name Type Attributes Description
key String The key to drop data for in the storage.
callback function <optional>
The method to call when the data is dropped.
Source:

encode(val, finished)

Starts an encode waterfall process.
Parameters:
Name Type Description
val * The data to be encoded.
finished function The callback to pass final data to.
Source:

init(db)

The init method that can be overridden or extended.
Parameters:
Name Type Description
db Db The ForerunnerDB database instance.
Source:

load(key, callbackopt)

Loads and decodes data from the passed key.
Parameters:
Name Type Attributes Description
key String The key to retrieve data from in the persistent storage.
callback function <optional>
The method to call when the load process has completed.
Source:

mode(type) → {*}

Gets / sets the persistent storage mode (the library used to persist data to the browser - defaults to localForage).
Parameters:
Name Type Description
type String The library to use for storage. Defaults to localForage.
Source:
Returns:
Type
*

save(key, data, callbackopt)

Encodes passed data and then stores it in the browser's persistent storage layer.
Parameters:
Name Type Attributes Description
key String The key to store the data under in the persistent storage.
data Object The data to store under the key.
callback function <optional>
The method to call when the save process has completed.
Source: