Storage that can be used like a localStorage easy-to-use on ServiceWorker.
npm install git://github.com/RyotaSugawara/serviceworker-storage.git
create instance.
- name: your storage name.
- version: version number.
import ServiceWorkerStorage from 'serviceworker-storage';
const storage = new ServiceWorkerStoarge('MyStorage', 1);
get item by key.
- key: storage unique key.
storage.getItem('key').then(value => {
console.log(value);
});
set item to key.
- key: storage unique key.
- value: value you want to save.
storage.setItem(key, value);
remove item by key.
- key: storage unique key.
storage.removeItem(key);
clear storage.
storage.clear();