redux-async-initial-state
Advanced tools
Comparing version
@@ -17,7 +17,7 @@ 'use strict'; | ||
loaded: false, | ||
error: false | ||
error: null | ||
}; | ||
function innerReducer() { | ||
var state = arguments.length <= 0 || arguments[0] === undefined ? initialState : arguments[0]; | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
var action = arguments[1]; | ||
@@ -29,3 +29,3 @@ | ||
loaded: false, | ||
error: false, | ||
error: null, | ||
loading: true | ||
@@ -36,3 +36,3 @@ }; | ||
loaded: true, | ||
error: false, | ||
error: null, | ||
loading: false | ||
@@ -43,3 +43,3 @@ }; | ||
loaded: false, | ||
error: true, | ||
error: action.payload.error, | ||
loading: false | ||
@@ -46,0 +46,0 @@ }; |
{ | ||
"name": "redux-async-initial-state", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "It is simple redux middleware that helps you load redux initial state asynchronously", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -10,3 +10,3 @@ Redux Async Initial State | ||
```javascript | ||
```bash | ||
npm install --save redux-async-initial-state | ||
@@ -31,3 +31,3 @@ ``` | ||
```javascript | ||
```bash | ||
npm install --save redux-async-initial-state | ||
@@ -41,3 +41,3 @@ ``` | ||
```javascript | ||
import { createStore } from 'redux' | ||
import { createStore, combineReducers } from 'redux' | ||
import * as reducers from 'reducers' | ||
@@ -53,3 +53,3 @@ | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import { createStore, applyMiddleware, combineReducers, compose } from 'redux'; | ||
import * as reducers from 'reducers'; | ||
@@ -76,4 +76,6 @@ import * as asyncInitialState from 'redux-async-initial-state'; | ||
const storeCreator = applyMiddleware(asyncInitialState.middleware(loadStore)); | ||
const store = storeCreator(reducer); | ||
const store = createStore( | ||
reducer, | ||
compose(applyMiddleware(asyncInitialState.middleware(loadStore))) | ||
); | ||
``` | ||
@@ -115,2 +117,3 @@ | ||
```javascript | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
@@ -117,0 +120,0 @@ |
9595
0.66%127
2.42%