Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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