rt-storage
v0.1.0
Published
A real time storage library based on localforage and rxjs.
Maintainers
Readme
rt-storage
A real time storage library based on localforage and rxjs.
Install
via npm:
npm install rt-storagevia yarn:
yarn add rt-storageUse
With Webpack:
import RTStorage from 'rt-storage';
const storage = new RTStorage({ name: 'test-db' });
storage.subscribe((event) => {
console.dir(event)
});With CDN:
<script src="https://unpkg.com/[email protected]/dist/localforage.js"></script>
<script src="https://unpkg.com/[email protected]/bundles/rxjs.umd.min.js"></script>
<script src="https://wzrd.in/standalone/uuid%2Fv4@latest"></script>
<script src="https://unpkg.com/[email protected]/build/index.js"></script>
<script>
var storage = new RTStorage({ name: 'test-db' });
storage.subscribe((event) => {
console.dir(event)
});
</script>API
getItem
Get data from storage:
storage.getItem(storageKey)Return promise
setItem
Set data into storage:
storage.setItem(storageKey, data)Return promise.
subscribe
Subscribe storage data changed event:
const subscription = storage.subscribe((event) => console.dir(event));
// subscription.unsubscribe
storage.subscribe('storageKey', (data) => console.dir(data));