Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/archakov06/smit
😎 Tiny library tracking changes in the LocalStorage
https://github.com/archakov06/smit
localstorage smit storage tiny tracking
Last synced: about 3 hours ago
JSON representation
😎 Tiny library tracking changes in the LocalStorage
- Host: GitHub
- URL: https://github.com/archakov06/smit
- Owner: Archakov06
- Created: 2019-09-07T10:46:47.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-13T08:56:16.000Z (about 5 years ago)
- Last Synced: 2024-08-08T15:44:56.207Z (3 months ago)
- Topics: localstorage, smit, storage, tiny, tracking
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```js
// ES6
import smit from 'smit';// CommonJS
var smit = require('smit').default;// UMD
// Just one function (IIFE)
```
## Usage
```js
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](https://codesandbox.io/s/thirsty-gagarin-2dnp9) | [Demo](https://2dnp9.csb.app/)
**VueJS:** [Source](https://codesandbox.io/s/vue-template-f17f6) | [Demo](https://f17f6.csb.app/)
**ReactJS:** [Source](https://codesandbox.io/s/happy-mclean-umjel) | [Demo](https://umjel.csb.app/)### Audio
**VanillaJS:** [Source](https://trycode.pw/c/J0ERM) | [Demo](https://trycode.pw/c/J0ERM.html)
## Motivation
...
## How it works?
...
## License
[MIT License](https://opensource.org/licenses/MIT) © [Archakov Dennis](https://archakov.im/about)