@ima/plugin-local-storage
TypeScript icon, indicating that this package has built-in type declarations

4.0.3 • Public • Published

@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');

Package Sidebar

Install

npm i @ima/plugin-local-storage

Weekly Downloads

0

Version

4.0.3

License

MIT

Unpacked Size

42.9 kB

Total Files

21

Last publish

Collaborators

  • corvidism
  • mjancarik
  • filipoliko
  • matej.marcisovsky
  • jsimck
  • hartja
  • zdenek.lastuvka
  • jan.kucera
  • ondrej.sliva