Constructs a storage driver instance setting
the actual storage provider as storageProvider
property. By default, this class uses window.localStorage
.
The storage provider or arrow function, i.e. the "location".
The storage provider used for persistence using this
storage driver. This should generally use window.localStorage
as a default.
You can also provide an arrow function which consists
in reading one value of said persistence layer. Note that
the arrow function must return a string formatted value.
Helper method to read one value from the linked
storageProvider using either the getItem
method or calling the forward predicate if an arrow
function is passed to overwrite the persistence
for the active language definition.
The storage key that must be read.
The fallback value in case the value does not exist.
Helper method to write one value using the linked
storageProvider using the setItem
method.
Note that persistence is not available if using arrow
functions as the storage provider. Currently persistence
is only available in browser runtime with window.localStorage
.
The storage key that must be read.
Generated using TypeDoc
This class handles persistence using in a simple form using either of
window.localStorage
or aStorage
extending object, or a forward predicate that returns values for specific keys.The persistence uses a simple key-value format where scalar value types are kept in their original type whereas objects are flattened to their corresponding JSON representation.
Note that if you are using an arrow function to read the key-value store, persistence will not be possible.
Using the StorageDriver class
Properties
The storage provider used for persistence (defaults to window.localStorage).
v0.1.0