Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/embbnux/rt-storage
Real time storage
https://github.com/embbnux/rt-storage
Last synced: 28 days ago
JSON representation
Real time storage
- Host: GitHub
- URL: https://github.com/embbnux/rt-storage
- Owner: embbnux
- Created: 2019-04-22T08:30:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T04:52:50.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T02:31:00.045Z (about 1 month ago)
- Language: TypeScript
- Size: 988 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rt-storage
A real time storage library based on localforage and rxjs.
## Install
via npm:
```
npm install rt-storage
```via yarn:
```
yarn add rt-storage
```## Use
With Webpack:
```js
import RTStorage from 'rt-storage';const storage = new RTStorage({ name: 'test-db' });
storage.subscribe((event) => {
console.dir(event)
});
```With CDN:
```html
var storage = new RTStorage({ name: 'test-db' });
storage.subscribe((event) => {
console.dir(event)
});```
## API
### getItem
Get data from storage:
```js
storage.getItem(storageKey)
```Return promise
### setItem
Set data into storage:
```js
storage.setItem(storageKey, data)
```Return promise.
### subscribe
Subscribe storage data changed event:
```js
const subscription = storage.subscribe((event) => console.dir(event));
// subscription.unsubscribe
storage.subscribe('storageKey', (data) => console.dir(data));
```