Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-cz committed Apr 14, 2019
0 parents commit 2ce4c17
Show file tree
Hide file tree
Showing 8 changed files with 1,691 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist
/node_modules
/yarn-error.log
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.0.0 - 2018-01-11
### Added
- Initial release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Piotr Konieczny

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Redux persist idb storage

Storage adapter to use [IndexedDB] via [idb](https://www.npmjs.com/package/idb) v3 with [redux-persist](https://github.com/rt2zz/redux-persist) ripped from [idb Examples](https://github.com/jakearchibald/idb/tree/v3.0.0#keyval-store) section

## Installation

```sh
npm install --save @piotr-cz/redux-persist-idb-storage
```
or

```
yarn add @piotr-cz/redux-persist-idb-storage
```

## Requirements

- [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) support/ polyfill

## Setup

Import the storage and include it in `persistConfig` when creating Redux store:

```js
// configureStore.js

// using CommonJS modules
import createIdbStorage from '@piotr-cz/redux-persist-idb-storage'

// using ES6 modules
import createIdbStorage from '@piotr-cz/redux-persist-idb-storage/src'

const persistConfig = {
key: 'root',
storage: createIdbStorage({name: 'myApp', storeName: 'keyval'}),
serialize: false, // Data serialization is not required and helps allows DevTools to inspect storage value
}

// ...
```

### Options

See [idb API](https://github.com/jakearchibald/idb/tree/v3.0.2#api)

- _{string}_ name - Defaults to `keyval-store`
- _{string}_ storeName - Defaults to `keyval`
- _{number}_ version - Defaults to `1`
- _{function}_ upgradeCallback - Defaults to `upgradeDb => upgradeDb.createObjectStore(options.storeName)`

## Notes

- idb dependency is locked to version ^3.0.0 as [4+ uses](https://github.com/jakearchibald/idb/blob/v4.0.3/changes.md#new-stuff) [proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) which are not supported in older browsers
Loading

0 comments on commit 2ce4c17

Please sign in to comment.