Seznam IMA.js local-storage plugin
npm install @ima/plugin-local-storageThis is the local-storage plugin for the IMA.js application.
You can visit our site imajs.io.
``bash`
npm install @ima/plugin-local-storage --save
`javascript
// /app/build.js
var vendors = {
common: [
'@ima/plugin-local-storage'
]
};
``javascript
// /app/config/bind.js
import { LocalStorage } from '@ima/plugin-local-storage';
oc.bind('LocalStorage', LocalStorage);
``javascript
// /app/config/service.js
const localStorage = oc.get('LocalStorage');
if ($window.isClient()) {
...
// initializes local storage
localStorage.init();
...
}
`
The localStorage class extends ima storage interface. You can easy use common storage methods like has, get, set, delete, clear, etc.
`javascript
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');
``