- dummyStorageAdapter
- localStorageAdapter
- nativeStorageAdapter
- persistentWritable
- sessionStorageAdapter
▸ dummyStorageAdapter<T>(): ItemStorage‹T›
Generates an dummy ItemStorage that never sets anything and always returns { present: false }
Type parameters:
▪ T
Returns: ItemStorage‹T›
an ItemStorage
▸ localStorageAdapter<T>(key
: string, mapper?
: StorageMapper‹T, string›): ItemStorage‹T›
Generates an ItemStorage based on the localStorage
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
key |
string | the key in the localStorage |
mapper? |
StorageMapper‹T, string› | (optional) an object containing a serialize and deserialize function. Defaults to JSON.stringify and JSON.parse respectively |
Returns: ItemStorage‹T›
an ItemStorage
▸ nativeStorageAdapter<T>(key
: string, nativeStorage
: Storage, mapper?
: StorageMapper‹T, string›): ItemStorage‹T›
Generates an ItemStorage based on an implementation of the native Storage API
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
key |
string | key needed to access the record in the storage |
nativeStorage |
Storage | localStorage, sessionStorage or any other implementation of the Storage API |
mapper? |
StorageMapper‹T, string› | (optional) an object containing a serialize and deserialize function |
Returns: ItemStorage‹T›
an ItemStorage
▸ persistentWritable<T>(initialValue
: T, __namedParameters
: object): PersistentWritable‹T›
Creates a Persistent Writable. This Writable store will be initialized with initialValue if the passed item storage doesn't contain any value, otherwise it will be initialized with the value found in the item storage
Type parameters:
▪ T
Parameters:
▪ initialValue: T
the value the store will contain on its first initialization
▪ __namedParameters: object
Name | Type | Default |
---|---|---|
resetOnInitFailure |
boolean | true |
start |
undefined | function | - |
storage |
ItemStorage‹T› | - |
Returns: PersistentWritable‹T›
a persistent writable store
▸ sessionStorageAdapter<T>(key
: string, mapper?
: StorageMapper‹T, string›): ItemStorage‹T›
Generates an ItemStorage based on the sessionStorage
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
key |
string | the key in the sessionStorage |
mapper? |
StorageMapper‹T, string› | (optional) an object containing a serialize and deserialize function. Defaults to JSON.stringify and JSON.parse respectively |
Returns: ItemStorage‹T›
an ItemStorage