Constructor
new FormSaver(gunopt)
FormSaver constructor
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
gun |
object |
<optional> |
An optional existing GUN instance |
Methods
(async) discardBackup()
Discards saved data to clean up memory
getBackup(form) → {Promise.<object>}
Fetches your backup data and displays them on the form
Parameters:
Name | Type | Description |
---|---|---|
form |
string | HTMLFormElement | Form name or form element |
Returns:
Fetched raw backup data
- Type
- Promise.<object>
getRawBackup() → {object}
Get raw backup data
Returns:
- Raw backup data
- Type
- object
setBackup(form) → {Promise.<string>}
Fetches your current form data and saves it to the backup
Parameters:
Name | Type | Description |
---|---|---|
form |
string | HTMLFormElement | Form name or form element |
Returns:
If resolved, your backup key
- Type
- Promise.<string>
setRawBackup(data) → {Promise.<string>}
Set raw backup data
Parameters:
Name | Type | Description |
---|---|---|
data |
object | Raw data object to save |
Returns:
If resolved, your backup key
- Type
- Promise.<string>
submitBackup(backup) → {Promise.<string>}
Submit an existing backup key
Parameters:
Name | Type | Description |
---|---|---|
backup |
string | Encoded backup key |
Returns:
Confirmation of submission
- Type
- Promise.<string>