smit
Is a tiny library ~270 byte localStorage emitter.
Last updated 3 months ago by archakov06 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install smit 
SYNC missed versions from official npm registry.

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?

...

License

MIT License © Jason Miller

Current Tags

  • 1.0.1                                ...           latest (3 months ago)

2 Versions

  • 1.0.1                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |