Skip to main content

SipaState

SipaState​

Tool class to store global states at different persistence levels.

Level 1 (variable): Data will be lost after reload (SipaState.LEVEL.VARIABLE) You can even store references and functions!

Level 2 (session): Data will be lost when browser is closed (SipaState.LEVEL.SESSION) You can not store references but thanks to SipaSerializer isolated functions are possible!

Level 3 (storage): Data will be lost when clearing browser cache only (SipaState.LEVEL.STORAGE) You can not store references but thanks to SipaSerializer isolated functions are possible!

SipaState.set(key, value, options)​

Set a value with the given persistence level, by default SipaState.LEVEL.SESSION

ParamTypeDefaultDescription
keystring
valueany
optionsobject
options.levelLevel'session'
options.forcebooleanfalseoverwrite value, if it is set at another level already

SipaState.setVariable(key, value, options)​

Set value in persistence level 1 (variable)

ParamTypeDefaultDescription
keystring
valueany
optionsobject
options.forcebooleanfalseoverwrite value without throwing error, if it is set at another level already

SipaState.setSession(key, value, options)​

Set value in persistence level 2 (session)

ParamTypeDefaultDescription
keystring
valueany
optionsobject
options.forcebooleanfalseoverwrite value without throwing error, if it is set at another level already

SipaState.setStorage(key, value, options)​

Set value in persistence level 3 (storage)

ParamTypeDefaultDescription
keystring
valueany
optionsobject
options.forcebooleanfalseoverwrite value without throwing error, if it is set at another level already

SipaState.getLevel(key) → SipaState.LEVEL | null​

Get the persistence level of the value stored at the given key. If key is not set at any level, returns null.

ParamType
keystring

SipaState.hasKey(key) → boolean​

Check if key is set already at any persistence level

ParamType
keystring

SipaState.get(key)​

Get the value of the given key. Persistence level does not matter and is implicit.

ParamType
keystring

SipaState.getVariables() → Object.<String, any>​

Get all entries of persistence level 1 (variables)

SipaState.getSession() → Object.<String, any>​

Get all entries of persistence level 2 (session)

SipaState.getStorage() → Object.<String, any>​

Get all entries of persistence level 3 (storage)

SipaState.getAll() → Object.<String, any>​

Get all stored entries

SipaState.getKeys() → Array.<String>​

Get all keys

SipaState.remove(key) → boolean​

Remove the stored value of the given key(s)

Returns: boolean - true if value of any key was set and has been removed. False if no key did exist.

ParamTypeDescription
keystring | Arraykey or keys to remove

SipaState.removeAll() → boolean​

Delete all stored data - alias method for reset()

Returns: boolean - true if one or more entries have been deleted

SipaState.reset() → boolean​

Delete all stored data

Returns: boolean - true if one or more entries have been deleted

SipaState.Level : 'variable' | 'session' | 'storage'​

Kind: static typedef of SipaState