This class provides a convenience wrapper around basic local storage support testing, saving and retrieving.
- Values are expected to be strings, return values will always be strings.
- If local storage is not supported the data will be saved for the life of the `store` instance as a fallback.
- See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
- Values are expected to be strings, return values will always be strings.
- If local storage is not supported the data will be saved for the life of the `store` instance as a fallback.
- See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
- Source:
Methods
(static) disable()
Disable using storage even if supported.
- To be called before `storymode.createApp()`.
- To be called before `storymode.createApp()`.
- Source:
(static) isEnabled() → {boolean}
Will be true if local storage is supported / enabled on the current device.
- Source:
Returns:
enabled
- Type
- boolean
(static) load(key) → {string|null}
Retrieve a value from local storage.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The storage key. |
- Source:
Returns:
value - If data for the key is not found then will return null.
- Type
- string | null
(static) remove(key)
Removes a key from local storage.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The storage key. |
- Source:
(static) removeAll()
Removes all storage data from the store instance.
- Source:
(static) save(key, val) → {boolean}
Save a value in local storage.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The storage key. |
val |
string | The string value to set. |
- Source:
Returns:
success - If false then data was saved to the `store` instance until the page is reloaded.
- Type
- boolean
(static) setPrefix(prefix)
Override the default storage prefix.
- To be called before `storymode.createApp()`.
- To be called before `storymode.createApp()`.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
string | Will be added as a prefix to local storage variables. |
- Source: