Constructor
new LocalStorage(opts)
- Source:
- See:
Creates a new LocalStorage instance.
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
opts |
Object | Options for Properties
|
Methods
destroy()
- Source:
destroy unregisters all handlers and frees internal members.
It does not delete any of the data in local storage.
get(item) → {Object|string}
- Source:
get returns the storage value for item.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
string | The |
Returns:
- Type
- Object | string
register(handler) → {func}
- Source:
register registers an event handler for any change in the storage. Changes to specific items
and clearing the storage will fire handler.
Parameters:
| Name | Type | Description |
|---|---|---|
handler |
func | Handler with signature |
Returns:
An unregister function.
- Type
- func
registerItem(item, handler) → {func}
- Source:
registerItem registers an event handler for any change in storage for a specific storage item
or key.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
string | The |
handler |
func | Handler with signature |
Returns:
An unregister function.
- Type
- func
remove(item)
- Source:
remove removes the data in the named item.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
string | The |
set(item, value)
- Source:
set sets the storage item to value. value will be JSON encoded.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
string | The |
value |
Object | string | The |