1.0.5 • Published 3 years ago
@varandas/capacitator-storage-wrapper v1.0.5
capacitator-storage-wrapper
A simple wrapper for ionic capacitator Storage plugin.
Motivation
I needed an easier and faster way to use the capacitator storage plugin.
Usage
Install with your favourite package manager:
npm i @varandas/capacitator-storage-wrapper
OR
yarn add @varandas/capacitator-storage-wrapper
import Storage from '@varandas/capacitator-storage-wrapper'
// item we want to save:
const item = {
foo: 'bar',
}
// the key we want to use
const key = 'item name'
// saving the item
await Storage.setItem(key, item)
// retrieving the item
try {
const data = await Storage.getItem(key)
// process data
} catch(error) {
// Key was not found, handle exeption
}
// remove item
await Storage.removeItem(key)
// get all keys
const keys = await Storage.keys()
// clear all keys and values
await Storage.clear()