Skip to content

Instantly share code, notes, and snippets.

@hwclass
Created December 1, 2022 19:23
Show Gist options
  • Save hwclass/ab58dd7799d25287b74611290839fcff to your computer and use it in GitHub Desktop.
Save hwclass/ab58dd7799d25287b74611290839fcff to your computer and use it in GitHub Desktop.
// if user accepts, this will give `persistent` (true/false, 1/0) back to the promise itself
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then((persistent) => {
if (persistent) {
// let the user know about what will happen
"Great! You will never loose your data even after clearing the cache of your browser."
} else {
"Ups, you need to activate storage within your browser to get notified."
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment