Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

Commit 0e1dc97

Browse files
remove engines and decorators
1 parent 74d9843 commit 0e1dc97

21 files changed

+50
-835
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# build artefacts
22
/build/
3-
/engines/
43

54
# npm
65
/node_modules/

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ node_modules/: package.json
1919
clean:
2020
echo "> Cleaning ..."
2121
rm -rf build/
22-
rm -rf engines/
2322

2423
mrproper: clean
2524
echo "> Cleaning deep ..."
@@ -32,7 +31,6 @@ mrproper: clean
3231
build: clean install
3332
echo "> Building ..."
3433
$(BIN)/babel src/ --out-dir build/
35-
mv -f ./build/engines ./
3634

3735
build-watch: clean install
3836
echo "> Building forever ..."
@@ -48,11 +46,11 @@ lint: install
4846

4947
test: install
5048
echo "> Testing ..."
51-
$(BIN)/mocca --require src/__tests__/init.js --globals localStorage
49+
$(BIN)/mocca
5250

5351
test-watch: install
5452
echo "> Testing forever ..."
55-
$(BIN)/mocca --require src/__tests__/init.js --globals localStorage --watch
53+
$(BIN)/mocca --watch
5654

5755
#
5856
# PUBLISH

README.md

Lines changed: 38 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
[redux-storage][]
2-
=================
1+
# [redux-storage][]
32

43
[![build](https://travis-ci.org/michaelcontento/redux-storage.svg)](https://travis-ci.org/michaelcontento/redux-storage)
54
[![dependencies](https://david-dm.org/michaelcontento/redux-storage.svg)](https://david-dm.org/michaelcontento/redux-storage)
@@ -15,8 +14,9 @@ Save and load the [Redux][] state with ease.
1514
## Features
1615

1716
* Flexible storage engines
18-
* [localStorage][] based on `window.localStorage`
19-
* [reactNativeAsyncStorage][] based on `react-native/AsyncStorage`
17+
* [localStorage][]: based on window.localStorage
18+
* Or for environments without `Promise` support [localStorageFakePromise][]
19+
* [reactNativeAsyncStorage][]: based on `react-native/AsyncStorage`
2020
* Storage engines can be async
2121
* Load and save actions that can be observed
2222
* [SAVE][]: `{ type: 'REDUX_STORAGE_SAVE', payload: /* state tree */ }`
@@ -25,13 +25,15 @@ Save and load the [Redux][] state with ease.
2525
* [debounce][]: batch multiple save operations
2626
* [filter][]: only store a subset of the whole state tree
2727
* [immutablejs][]: load parts of the state tree as [Immutable][] objects
28-
* [migrate][]: Versioned storage with migrations
2928
* Black- and whitelist actions from issuing a save operation
3029

3130
## Installation
3231

3332
npm install --save redux-storage
3433

34+
And you need to install at least one [redux-storage-engine][npm-engine], as
35+
[redux-storage][] is only the *"management core"*.
36+
3537
## Usage
3638

3739
```js
@@ -51,7 +53,7 @@ const reducer = storage.reducer(combineReducers(reducers));
5153
// Now it's time to decide which storage engine should be used
5254
//
5355
// Note: The arguments to `createEngine` are different for every engine!
54-
import createEngine from 'redux-storage/engines/reactNativeAsyncStorage';
56+
import createEngine from 'redux-storage-engine-localStorage';
5557
const engine = createEngine('my-save-key');
5658

5759
// And with the engine we can create our middleware function. The middleware
@@ -88,37 +90,12 @@ load(store)
8890

8991
## Details
9092

91-
### Engines
92-
93-
#### reactNativeAsyncStorage
94-
95-
This will use `AsyncStorage` out of [react-native][].
96-
97-
```js
98-
import createEngine from 'redux-storage/engines/reactNativeAsyncStorage';
99-
const engine = createEngine('my-save-key');
100-
```
101-
102-
**Warning**: [react-native][] is *not* a dependency of [redux-storage][]! You
103-
have to install it separately.
93+
### Engines & Decorators
10494

105-
#### localStorage
106-
107-
Stores everything inside `window.localStorage`.
108-
109-
```js
110-
import createEngine from 'redux-storage/engines/localStorage';
111-
const engine = createEngine('my-save-key');
112-
```
113-
114-
**Warning**: `localStorage` does not expose a async API and every save/load
115-
operation will block the JS thread!
116-
117-
**Warning**: Some browsers like IE<=11 does not support Promises. For this you
118-
might use [localStorageFakePromise][] which should work too - **BUT** other
119-
parts of [redux-storage][] might depend on Promises too! So this is a possible
120-
workaround for very limited cases only. The best solution is to use a polyfill
121-
like [es6-promise][].
95+
Both are published as own packages on npm. But as a convention all engines share
96+
the keyword [redux-storage-engine][npm-engine] and decorators can be found with
97+
[redux-storage-decorator][npm-decorator]. So it's pretty trivial to find all
98+
the additions to [redux-storage][] you need
12299

123100
### Actions
124101

@@ -170,82 +147,40 @@ import { SHOULD_SAVE } from './constants';
170147
const middleware = createMiddleware(engine, [], [ SHOULD_SAVE ]);
171148
```
172149

173-
### Decorators
150+
## License
174151

175-
Decorators simply wrap your engine instance and modify/enhance it's behaviour.
152+
The MIT License (MIT)
176153

177-
#### Filter
154+
Copyright (c) 2015 Michael Contento
178155

179-
Use this decorator to write only part of your state tree to disk.
180-
181-
It will write the state corresponding to the whitelisted keys minus the blacklisted ones.
182-
183-
```js
184-
import { decorators } from 'redux-storage'
185-
186-
engine = decorators.filter(engine, [
187-
'whitelisted-key',
188-
['nested', 'key'],
189-
['another', 'very', 'nested', 'key']
190-
],
191-
[
192-
'backlisted-key',
193-
['nested', 'blacklisted-key'],
194-
]);
195-
```
196-
197-
#### Debounce
198-
199-
This decorator will delay the expensive save operation for the given ms. Every
200-
new change to the state tree will reset the timeout!
201-
202-
```js
203-
import { decorators } from 'redux-storage'
204-
205-
engine = decorators.debounce(engine, 1500);
206-
```
207-
208-
#### Immutablejs
209-
210-
Convert parts of the state tree into [Immutable][] objects on `engine.load`.
211-
212-
```js
213-
import { decorators } from 'redux-storage'
214-
215-
engine = decorators.immutablejs(engine, [
216-
['immutablejs-reducer'],
217-
['plain-object-reducer', 'with-immutablejs-key']
218-
]);
219-
```
220-
221-
#### Migration
222-
223-
Versioned storage with migrations.
224-
225-
```js
226-
import { decorators } from 'redux-storage'
227-
228-
engine = decorators.migrate(engine, 3);
229-
engine.addMigration(1, (state) => { /* migration step for 1 */ return state; });
230-
engine.addMigration(2, (state) => { /* migration step for 2 */ return state; });
231-
engine.addMigration(3, (state) => { /* migration step for 3 */ return state; });
232-
```
156+
Permission is hereby granted, free of charge, to any person obtaining a copy of
157+
this software and associated documentation files (the "Software"), to deal in
158+
the Software without restriction, including without limitation the rights to
159+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
160+
the Software, and to permit persons to whom the Software is furnished to do so,
161+
subject to the following conditions:
233162

234-
## Todo
163+
The above copyright notice and this permission notice shall be included in all
164+
copies or substantial portions of the Software.
235165

236-
- Write tests for everything!
166+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
168+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
169+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
170+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
171+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237172

173+
[npm-engine]: https://www.npmjs.com/browse/keyword/redux-storage-engine
174+
[npm-decorator]: https://www.npmjs.com/browse/keyword/redux-storage-decorator
238175
[Redux]: https://github.com/gaearon/redux
239176
[Immutable]: https://github.com/facebook/immutable-js
240177
[redux-storage]: https://github.com/michaelcontento/redux-storage
241178
[react-native]: https://facebook.github.io/react-native/
242-
[localStorage]: https://github.com/michaelcontento/redux-storage/blob/master/src/engines/localStorage.js
243-
[localStorageFakePromise]: https://github.com/michaelcontento/redux-storage/blob/master/src/engines/localStorageFakePromise.js
244-
[reactNativeAsyncStorage]: https://github.com/michaelcontento/redux-storage/blob/master/src/engines/reactNativeAsyncStorage.js
179+
[localStorage]: https://github.com/michaelcontento/redux-storage-engine-localStorage
180+
[localStorageFakePromise]: https://github.com/michaelcontento/redux-storage-engine-localStorageFakePromise
181+
[reactNativeAsyncStorage]: https://github.com/michaelcontento/redux-storage-engine-reactNativeAsyncStorage
245182
[LOAD]: https://github.com/michaelcontento/redux-storage/blob/master/src/constants.js#L1
246183
[SAVE]: https://github.com/michaelcontento/redux-storage/blob/master/src/constants.js#L2
247-
[debounce]: https://github.com/michaelcontento/redux-storage/blob/master/src/decorators/debounce.js
248-
[filter]: https://github.com/michaelcontento/redux-storage/blob/master/src/decorators/filter.js
249-
[immutablejs]: https://github.com/michaelcontento/redux-storage/blob/master/src/decorators/immutablejs.js
250-
[migrate]: https://github.com/michaelcontento/redux-storage/blob/master/src/decorators/migrate.js
251-
[es6-promise]: https://www.npmjs.com/package/es6-promise
184+
[debounce]: https://github.com/michaelcontento/redux-storage-decorator-debounce
185+
[filter]: https://github.com/michaelcontento/redux-storage-decorator-filter
186+
[immutablejs]: https://github.com/michaelcontento/redux-storage-decorator-immutablejs

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-storage",
3-
"version": "2.2.0",
3+
"version": "3.0.0",
44
"description": "Persistence layer for redux with flexible backends",
55
"main": "build/index.js",
66
"jsnext:main": "src/index.js",
@@ -15,9 +15,6 @@
1515
"keywords": [
1616
"redux",
1717
"redux-middleware",
18-
"react-native",
19-
"promise",
20-
"middleware",
2118
"fsa",
2219
"flux-standard-action",
2320
"flux",
@@ -29,7 +26,6 @@
2926
"author": "Michael Contento <michaelcontento@gmail.com>",
3027
"files": [
3128
"build/",
32-
"engines/",
3329
"src",
3430
"!**/__tests__/**"
3531
],
@@ -45,17 +41,15 @@
4541
"eslint": "^1.10.3",
4642
"eslint-config-michaelcontento": "^1.1.1",
4743
"eslint-plugin-mocha-only": "0.0.3",
44+
"immutable": "^3.7.6",
4845
"mocca": "^0.3.0",
4946
"release-it": "^2.3.1"
5047
},
5148
"dependencies": {
52-
"immutable": "^3.7.6",
5349
"lodash.isarray": "^4.0.0",
5450
"lodash.isfunction": "^3.0.7",
5551
"lodash.isobject": "^3.0.2",
5652
"lodash.merge": "^4.0.2",
57-
"lodash.set": "^4.0.0",
58-
"lodash.unset": "^4.1.0",
5953
"redux-actions": "^0.9.0"
6054
},
6155
"peerDependencies": {

src/__tests__/index-test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import defaultImport from '../';
22
import * as fullImport from '../';
3-
import { LOAD, SAVE, createLoader, createMiddleware, decorators, reducer } from '../';
3+
import { LOAD, SAVE, createLoader, createMiddleware, reducer } from '../';
44

55
describe('index', () => {
66
it('should export everything by default', () => {
@@ -25,11 +25,6 @@ describe('index', () => {
2525
createMiddleware.should.be.a.func;
2626
});
2727

28-
it('should export decorators', () => {
29-
decorators.should.be.a.object;
30-
decorators.should.not.be.empty;
31-
});
32-
3328
it('should export reducer', () => {
3429
reducer.should.be.a.func;
3530
});

src/__tests__/init.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/decorators/__tests__/debounce-test.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)