feat(local-storage): add clearItem, clearAll instance methods

This commit is contained in:
Eric Y Liu 2021-07-09 11:57:11 -07:00
commit 6c478b8193
7 changed files with 111 additions and 8 deletions

View file

@ -15,6 +15,22 @@
*/
export let value = "";
/**
* Remove the persisted key value from the browser's local storage
* @type {() => void}
*/
export function clearItem() {
localStorage.removeItem(key);
}
/**
* Clear all key values from the browser's local storage
* @type {() => void}
*/
export function clearAll() {
localStorage.clear();
}
import { onMount, afterUpdate, createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();