@ima/plugin-local-storage
v4.0.3
Published
Seznam IMA.js local-storage plugin
Downloads
273
Readme
@ima/plugin-local-storage
This is the local-storage plugin for the IMA.js application. You can visit our site imajs.io.
Installation
npm install @ima/plugin-local-storage --save
// /app/build.js
var vendors = {
common: [
'@ima/plugin-local-storage'
]
};
// /app/config/bind.js
import { LocalStorage } from '@ima/plugin-local-storage';
oc.bind('LocalStorage', LocalStorage);
// /app/config/service.js
const localStorage = oc.get('LocalStorage');
if ($window.isClient()) {
...
// initializes local storage
localStorage.init();
...
}
Usage
The localStorage class extends ima storage interface. You can easy use common storage methods like has, get, set, delete, clear, etc.
const exist = localStorage.has('key');
if (!exist) {
localStorage.set('key', { some: 'value' }, { expired: 24 * 60 * 60 });
}
const value = localStorage.get('key');
// some logic
localStorage.delete('key');