smit
v1.0.1
Published
Is a tiny library ~270 byte localStorage emitter.
Downloads
2
Maintainers
Readme
Smit
Is a tiny library 🔥~270 byte localStorage emitter.
Smit has no dependencies, supports all browsers and IE9+.
- Very small: 270 bytes gzipped (ES module 260 gzipped).
- Tiny name: just use
smit
. - Only one function
Install
npm install smit
or
yarn add smit
Module usage
If you are in a CommonJS environment (eg Node), then you will need to add .default to your import:
// ES6
import mitt from 'mitt';
// CommonJS
var mitt = require('mitt').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>
Usage
import smit from 'smit';
const storage = smit();
// listen of one key
storage.on('title', title => console.log('title updated', title));
// listen of many keys
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();
Examples
...
Motivation
...
How it's work?
...