Is a tiny library ๐ฅ~270 (gziped) byte localStorage emitter. Smit has no dependencies, supports all browsers and IE9+.
npm install smit or
yarn add smit If you are in a CommonJS environment (eg Node), then you will need to add .default to your import:
// ES6 import smit from 'smit'; // CommonJS var smit = require('smit').default; // UMD <script src="https://unpkg.com/smit/dist/smit.umd.js"></script> // Just one function (IIFE) <script src="https://unpkg.com/smit/dist/smit.iife.js"></script>import smit from 'smit'; const storage = smit(); // Callback called when a key "title" is updated in localStorage storage.on('title', title => console.log('title updated', title)); // Listen of many keys in localStorage storage.on('foo', value => console.log('foo', value)).on('bar', value => console.log('bar', value)); // Remove listener storage.off('foo'); // Remove all listeners storage.off(); // destroy the smit storage.destroy();If you want to check how this smit works, open any of the following demos in two tabs.
VanillaJS: Source | Demo
VueJS: Source | Demo
ReactJS: Source | Demo
...
...