Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Smit

Is a tiny library πŸ”₯~270 (gziped) byte localStorage emitter. Smit has no dependencies, supports all browsers and IE9+.

Install

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>

Usage

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();

Examples

If you want to check how this smit works, open any of the following demos in two tabs.

Chat

VanillaJS: Source | Demo
VueJS: Source | Demo
ReactJS: Source | Demo

Audio

VanillaJS: Source | Demo

Motivation

...

How it works?

...

License

MIT License Β© Archakov Dennis

About

😎 Tiny library tracking changes in the LocalStorage

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /