Classes
Type Definitions
SimpleStorageDictionary
- Source:
A utility type for all the differents dictionary SimpleStorage
manages.
Type:
SimpleStorageEntriesOptions
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
enabled |
boolean |
<optional> |
false
|
Whether or not to use the entries functionality. Enabling it means that all the "xxxEntry" methods will be available and that, when deleted or resetted, the storage will become an empty object. |
expiration |
number |
<optional> |
3600
|
The amount of seconds relative to the current time that needs to pass in order to consider an entry expired. |
deleteExpired |
boolean |
<optional> |
true
|
Whether or not to delete expired entries (both when loading the storage and when trying to access the entries). |
saveWhenDeletingExpired |
boolean |
<optional> |
true
|
Whether or not to sync the storage after deleting an expired entry. |
Type:
SimpleStorageEntry
- Source:
Properties:
Name | Type | Description |
---|---|---|
time |
number | The timestamp of when the entry was first created. |
value |
Object | The actual data for the entry. |
Type:
SimpleStorageLogger
- Source:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
warn |
SimpleStorageLoggerWarnFn |
<nullable> |
Prints out a warning message. Either
this or |
warning |
SimpleStorageLoggerWarnFn |
<nullable> |
Prints out a warning message. Either
this or |
Type:
SimpleStorageLoggerWarnFn(message)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
message |
string | The message to log the warning for. |
SimpleStorageOptions
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initialize |
boolean |
<optional> |
true
|
Whether or not to initialize the service right from the constructor. It means that it will validate the storage, check for existing data and sync it on the class. This can be disabled in case you need to do something between the constructor and the initialization. |
window |
Window |
<optional> |
The |
|
logger |
SimpleStorageLogger |
<optional> <nullable> |
A custom logger to print out the warnings when the class needs to do a fallback to a different storage type. |
|
storage |
SimpleStorageStorageOptions |
<optional> |
These are all the options related to the storage itself: The type, the name and the key. |
|
entries |
SimpleStorageEntriesOptions |
<optional> |
These are the options for customizing the way the service works with entries. By default, the class saves any kind of object on the storage, but by using entries you can access them by name and even define expiration time so they'll be removed after a while. |
|
tempStorage |
SimpleStorageDictionary |
<optional> |
{}
|
The |
Type:
SimpleStorageStorage
- Source:
Properties:
Name | Type | Description |
---|---|---|
name |
string | The name of the storage. |
isAvailable |
SimpleStorageStorageAvailableMethod | The method to check if the storage can be used or not. |
get |
SimpleStorageStorageGetMethod | The method used to read from the storage. |
set |
SimpleStorageStorageSetMethod | The method used to write on the storage. |
delete |
SimpleStorageStorageDeleteMethod | The method used to delete data from the storage. |
Type:
SimpleStorageStorageAvailableMethod(fallbackFromopt) → {boolean}
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
fallbackFrom |
string |
<optional> |
If the storage is being used as a fallback from another one that is not available, this parameter will have its name. |
Returns:
Whether or not the storage is available.
- Type
- boolean
SimpleStorageStorageDeleteMethod(key)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key used by the class to save data on the storage. |
SimpleStorageStorageGetMethod(key) → {SimpleStorageDictionary}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key used by the class to save data on the storage. |
Returns:
The contents from the storage.
SimpleStorageStorageOptions
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string |
<optional> |
'simpleStorage'
|
A reference name for the storage. |
key |
string |
<optional> |
'simpleStorage'
|
The key the class will use to store the data on the storage. |
typePriority |
Array.<SimpleStorageStorageType> |
<optional> |
['local', 'session', 'temp']
|
The priority list of types of storage the service will try to use when initialized. |
Type:
SimpleStorageStorageSetMethod(key, value)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key used by the class to save data on the storage. |
value |
Object | The data to save on the storage. |
SimpleStorageStorageType
- Source:
Type:
- 'local' | 'session' | 'temp'
SimpleStorageStorageTypes
- Source:
Properties:
Name | Type | Description |
---|---|---|
local |
SimpleStorageStorage | The methods to work with |
session |
SimpleStorageStorage | The methods to work with |
temp |
SimpleStorageStorage | The methods to work with the "temp storage". |