Skip to content

Archakov06/smit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

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

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors