Skip to content
This repository has been archived by the owner on Nov 9, 2019. It is now read-only.

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
Publish examples on pages.github.
  • Loading branch information
MrEfrem committed Nov 29, 2016
1 parent c7fee84 commit 1f7602c
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
lib
es
coverage
yarn.lock
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Redux-fly
The library is focused on to create simple API for:
The library is focused on to providing simple API for:
* Reducers registration at any time to any place in store of Redux.
* Fast creation and mutation of component state (similar to local state) which is saved in store of Redux.

Expand Down Expand Up @@ -110,7 +110,7 @@ export default compose(
registerReducers({
'ui counter': reducer
}),
connect((state) => ({ counter: state.ui.counter }), actionCreators)
connect((state) => ({ counter: state.ui.counter.value }), actionCreators)
)(Counter);
```

Expand All @@ -134,7 +134,8 @@ If you don’t yet use npm or a modern module bundler, and would rather prefer a
* [`getState(mountPath)(state)`](docs/API.md#getstatemountpathstate)
* [`registerReducers(reducers)`](docs/API.md#registerreducersreducers)

## Examples
## Examples ([view](https://mrefrem.github.io/))
All examples use [redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension) if it is installed in browser.
* [Counter](examples/counter). Example to use `redux-fly` component state.
* [Async](examples/async). Example to use of mix canonical reducer and `redux-fly` component state.
* [Universal](examples/universal). Example to use `redux-fly` for creation of component state and showin how to implement the universal rendering.
Expand Down
17 changes: 17 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ ReactDOM.render(
### `enhanceStore`
Function enhance an object of Redux store with the `registerReducers` method for gradual registration of reducer at any nesting level of Redux store.

#### `store.registerReducers(reducers)`
* `reducers`\(*Object*)
* `key`\(*string*): it defines reducer mounting path. Argument consist from object keys separated by spaces.
* `value`\(*Function*): it defines reducer.

#### Example
Creation of enhanced store:
```javascript
Expand Down Expand Up @@ -100,6 +105,18 @@ Creation of enhanced store and reducers registration with preloaded state:
const store = createStore(reducers, window.__INITIAL_STATE__, enhanceStore);
```

<br/>
Creation of enhanced store and registration of reducers later:
```javascript
import { createStore } from 'redux';
import { enhanceStore } from 'redux-fly';

const store = createStore(null, enhanceStore);
...
const reducer = (state, action) => { ... };
store.registerReducers({ 'ui component': reducer });
```

### `getState(mountPath)(state)`
Function to extract part of Redux state through mounting path.

Expand Down
9 changes: 7 additions & 2 deletions examples/async/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "async",
"version": "0.1.0",
"homepage": "https://mrefrem.github.io/async",
"private": true,
"devDependencies": {
"cpx": "^1.5.0",
"enzyme": "^2.6.0",
"gh-pages": "^0.12.0",
"react-addons-test-utils": "^15.3.2",
"react-scripts": "0.7.0"
"react-scripts": "0.7.0",
"rimraf": "^2.5.4"
},
"dependencies": {
"react": "^15.3.2",
Expand All @@ -20,6 +24,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"deploy": "npm run build && cpx \"build/**\" gh-pages/async && gh-pages -d gh-pages -r https://github.com/MrEfrem/mrefrem.github.io.git -b master -v async && rimraf gh-pages"
}
}
7 changes: 3 additions & 4 deletions examples/async/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { enhanceStore } from 'redux-fly'
import thunk from 'redux-thunk'

const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose

const store = createStore(null, composeEnhancers(enhanceStore, applyMiddleware(thunk)))
const target = document.getElementById('root')
Expand Down
9 changes: 7 additions & 2 deletions examples/counter/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "counter",
"version": "0.1.0",
"homepage": "https://mrefrem.github.io/counter",
"private": true,
"devDependencies": {
"cpx": "^1.5.0",
"enzyme": "^2.6.0",
"gh-pages": "^0.12.0",
"react-addons-test-utils": "^15.3.2",
"react-scripts": "0.7.0"
"react-scripts": "0.7.0",
"rimraf": "^2.5.4"
},
"dependencies": {
"react": "^15.3.2",
Expand All @@ -19,6 +23,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"deploy": "npm run build && cpx \"build/**\" gh-pages/counter && gh-pages -d gh-pages -r https://github.com/MrEfrem/mrefrem.github.io.git -b master -v counter && rimraf gh-pages"
}
}
7 changes: 3 additions & 4 deletions examples/counter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { Provider } from 'react-redux'
import { enhanceStore } from 'redux-fly'

const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose

const store = createStore(null, composeEnhancers(enhanceStore))
const target = document.getElementById('root')
Expand Down
9 changes: 7 additions & 2 deletions examples/nested_reused_components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"name": "nested_reused_components",
"version": "0.1.0",
"private": true,
"homepage": "https://mrefrem.github.io/nested-reused-components",
"devDependencies": {
"cpx": "^1.5.0",
"enzyme": "^2.6.0",
"gh-pages": "^0.12.0",
"react-addons-test-utils": "^15.3.2",
"react-scripts": "0.7.0"
"react-scripts": "0.7.0",
"rimraf": "^2.5.4"
},
"dependencies": {
"react": "^15.3.2",
Expand All @@ -20,6 +24,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"deploy": "npm run build && cpx \"build/**\" gh-pages/nested-reused-components && gh-pages -d gh-pages -r https://github.com/MrEfrem/mrefrem.github.io.git -b master -v nested-reused-components && rimraf gh-pages"
}
}
7 changes: 3 additions & 4 deletions examples/nested_reused_components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { enhanceStore } from 'redux-fly'
import Layout from './containers/page/Layout'

const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose

const store = createStore(null, composeEnhancers(enhanceStore))
const target = document.getElementById('root')
Expand Down
9 changes: 7 additions & 2 deletions examples/reused_components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"name": "reused_components",
"version": "0.1.0",
"private": true,
"homepage": "https://mrefrem.github.io/reused-components",
"devDependencies": {
"cpx": "^1.5.0",
"enzyme": "^2.6.0",
"gh-pages": "^0.12.0",
"react-addons-test-utils": "^15.3.2",
"react-scripts": "0.7.0"
"react-scripts": "0.7.0",
"rimraf": "^2.5.4"
},
"dependencies": {
"react": "^15.3.2",
Expand All @@ -20,6 +24,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"deploy": "npm run build && cpx \"build/**\" gh-pages/reused-components && gh-pages -d gh-pages -r https://github.com/MrEfrem/mrefrem.github.io.git -b master -v reused-components && rimraf gh-pages"
}
}
7 changes: 3 additions & 4 deletions examples/reused_components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { enhanceStore } from 'redux-fly'
import Layout from './containers/page/Layout'

const composeEnhancers =
process.env.NODE_ENV !== 'production' &&
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose

const store = createStore(null, composeEnhancers(enhanceStore))
const target = document.getElementById('root')
Expand Down
2 changes: 1 addition & 1 deletion examples/universal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react-redux": "^4.4.5",
"redbox-react": "^1.3.3",
"redux": "^3.5.2",
"redux-fly": "^0.0.1-alpha.3",
"redux-fly": "*",
"serialize-javascript": "^1.2.0",
"webpack": "^1.13.0",
"webpack-hot-middleware": "^2.9.1"
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"eslint": "^3.5.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.3.0",
"flow-bin": "^0.36.0",
"jest-cli": "^17.0.0",
"react": "^15.4.0",
"react-addons-test-utils": "^15.4.0",
Expand All @@ -70,8 +71,8 @@
},
"peerDependencies": {
"react": "15.x",
"redux": "3.x",
"react-redux": "4.x"
"react-redux": "4.x",
"redux": "3.x"
},
"jest": {
"testPathIgnorePatterns": [
Expand Down

0 comments on commit 1f7602c

Please sign in to comment.