springroll.SavedData Class

Module: Core

The SavedData functions use localStorage and sessionStorage, with a cookie fallback.

Methods

Properties

read

(
  • name
)
Mixed
static

Defined in read:100

Read the value of a saved variable

Parameters:

  • name String

    The name of the variable

Returns:

Mixed:

The value (run through JSON.parse()) or null if it doesn't exist

remove

(
  • name
)
static

Defined in remove:49

Remove a saved variable by name.

Parameters:

  • name String

    The name of the value to remove

reviver

(
  • key
  • value
)
Object
static

Defined in reviver:134

When restoring from JSON via JSON.parse, we may pass a reviver function. In our case, this will check if the object has a specially-named property (__classname). If it does, we will attempt to construct a new instance of that class, rather than using a plain old Object. Note that this recurses through the object.

Parameters:

  • key String

    each key name

  • value Object

    Object that we wish to restore

Returns:

Object:

The object that was parsed - either cast to a class, or not

write

(
  • name
  • value
  • [tempOnly=false]
)
static

Defined in write:66

Save a variable.

Parameters:

  • name String

    The name of the value to save

  • value Mixed

    The value to save. This will be run through JSON.stringify().

  • [tempOnly=false] Boolean optional

    If the value should be saved only in the current browser session.

WEB_STORAGE_SUPPORT

Boolean private static

A constant to determine if we can use localStorage and sessionStorage