From 785cc94f33bc5a7024e49bcc5d196476e72cd54d Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Wed, 28 Jun 2017 10:04:45 -0400 Subject: [PATCH 01/63] add npm scripts for docs --- package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c13709e..56721d08 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,12 @@ "lint:watch": "npm run lint -- --watch", "prepublish": "npm run lint && npm run test && npm run build", "test": "mocha --compilers js:babel-register src/**/*-test.js", - "test:watch": "npm run test -- --watch src/**/*-test.js" + "test:watch": "npm run test -- --watch src/**/*-test.js", + "docs:clean": "rimraf _book", + "docs:prepare": "gitbook install", + "docs:build": "npm run docs:prepare && gitbook build -g acdlite/redux-actions", + "docs:watch": "npm run docs:prepare && gitbook serve", + "docs:publish": "npm run docs:clean && npm run docs:build && cp CNAME _book && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:acdlite/redux-actions gh-pages --force" }, "files": [ "es", From 2869aa1c836f43dd801f55034cb03e12853212e8 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Wed, 28 Jun 2017 10:09:34 -0400 Subject: [PATCH 02/63] add cname for js.org --- CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 CNAME diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..64f4f907 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +redux-actions.js.org From 7e9a9cd87c134906e8f087ed29d94e5d4c0bda00 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Wed, 28 Jun 2017 10:14:02 -0400 Subject: [PATCH 03/63] add docs folder with some tocs --- docs/README.md | 5 +++++ docs/introduction/BeginnerTutorial.md | 7 +++++++ docs/introduction/README.md | 3 +++ 3 files changed, 15 insertions(+) create mode 100644 docs/README.md create mode 100644 docs/introduction/BeginnerTutorial.md create mode 100644 docs/introduction/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..6d902917 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,5 @@ +## Table of Contents + +* [Read Me](/README.md) +* [Introduction](/docs/introduction/README.md) + * [Beginner Tutorial](/docs/introduction/BeginnerTutorial.md) diff --git a/docs/introduction/BeginnerTutorial.md b/docs/introduction/BeginnerTutorial.md new file mode 100644 index 00000000..28fa56b0 --- /dev/null +++ b/docs/introduction/BeginnerTutorial.md @@ -0,0 +1,7 @@ +```bash +npm install --save redux-actions +``` + +The [npm](https://www.npmjs.com) package provides a [CommonJS](http://webpack.github.io/docs/commonjs.html) build for use in Node.js, and with bundlers like [Webpack](http://webpack.github.io/) and [Browserify](http://browserify.org/). It also includes an [ES modules](http://jsmodules.io/) build that works well with [Rollup](http://rollupjs.org/) and [Webpack2](https://webpack.js.org)'s tree-shaking. + +If you don’t use [npm](https://www.npmjs.com), you may grab the latest [UMD](https://unpkg.com/redux-actions@latest/dist) build from [unpkg](https://unpkg.com) (either a [development](https://unpkg.com/redux-actions@latest/dist/redux-actions.js) or a [production](https://unpkg.com/redux-actions@latest/dist/redux-actions.min.js) build). The UMD build exports a global called `window.ReduxActions` if you add it to your page via a ` + + + + + +
+ + + +``` + +Now that we are ready to write some JS let us create our default state for our counter. + +```js +const defaultState = { counter: 0 }; +``` + +Now if we want to see our default state we need to render it. +Lets get a reference to our main content and render our default state into the html. + +```js +const content = document.getElementById('content'); + +const render = () => { + content.innerHTML = defaultState.counter; +}; +render(); +``` + +With our default state and renderer in place we can start to use our libraries. `redux` and `redux-actions` can be found via the globals `window.Redux` and `window.ReduxActions`. Okay enough setup lets start to make something with `redux`! + +We are going to want a store for our defaultState. We can create one from `redux` using `createStore`. + +```js +const { createStore } = window.Redux; +``` + +We are going to want to create our first action and handle that action. + +```js +const { + createAction, + handleAction +} = window.ReduxActions; +``` + +Next lets create our first action, 'increment', using `createAction`. + +```js +const increment = createAction('INCREMENT'); +``` + +Next we are going to handle that action with `handleAction`. We can provide it our action to let it know which action to handle. A method to handle our state transformation, and the default state. + +```js +const reducer = handleAction(increment, (state, action) => ({ + counter: state.counter + 1 +}), defaultState); +``` + +`handleAction` produced a reducer for our `redux` store. Now that we have a reducer we can create a store. + +```js +const store = createStore(reducer, defaultState); +``` + +Now that we have a `store`, we can rewrite our `render` method to use it instead of the `defaultState`. We also want to `subscribe` our `render` to any changes the `store` might have for us. + +```js +const render = () => { + content.innerHTML = store.getState().counter; +}; + +store.subscribe(render); +``` + +We are ready to `dispatch` an action. Lets create an event listener for our increment button that will dispatch our `increment` action creator when clicked. + +```js +document.getElementById('increment').addEventListener('click', () => { + store.dispatch(increment()); +}); +``` + +If you try to click the increment button you should see the value is now going up by one on each click. + +We have one button working, so why don't we try to get the second one working by creating a new action for decrement. + +```js +const decrement = createAction('DECREMENT'); +``` + +Instead of using `handleAction` like we did for `increment`, we can replace it with our other tool `handleActions` which will let us handle both `increment` and `decrement` actions. + +```js +const { + createAction, + handleActions +} = window.ReduxActions; + +const reducer = handleActions({ + [increment](state) { + return { counter: state.counter + 1 } + }, + [decrement](state) { + return { counter: state.counter - 1 } + } +}, defaultState); +``` + +Now when we add a handler for dispatching our `decrement` action we can see both `increment` and `decrement` buttons now function appropriately. + +```js +document.getElementById('decrement').addEventListener('click', () => { + store.dispatch(decrement()); +}); +``` + +You might be thinking at this point we are all done. We have both buttons hooked up, and we can call it a day. Yet we have much optimizing to do. `redux-actions` has other tools we have not yet taken advantage of. So lets investigate how we can change the code to use the remaining tools and make the code less verbose. + +We have declarations for both `increment` and `decrement` action creators. We can modify these lines from using `createAction` to using `createActions` like so. + +```js +const { + createActions, + handleActions +} = window.ReduxActions; + +const { increment, decrement } = createActions('INCREMENT', 'DECREMENT'); +``` + +We can still do better though. What if we want an action like `'INCREMENT_FIVE'`? We would want to be able to create variations of our existing actions easily. We can abstract our logic in the reducer to our actions, making new permutations of existing actions easy to create. + +```js +const { increment, decrement } = createActions({ + 'INCREMENT': amount => ({ amount: 1 }), + 'DECREMENT': amount => ({ amount: -1 }) +}); + +const reducer = handleActions({ + [increment](state, { payload: { amount } }) { + return { counter: state.counter + amount } + }, + [decrement](state, { payload: { amount } }) { + return { counter: state.counter + amount } + } +}, defaultState); +``` + +Now that we have moved our logic, our `reducers` are looking identical. If only we could combine them somehow. Well we can! `combineActions` can be used to reduce multiple distinct actions with the same reducer. + +```js +const { + createActions, + handleActions, + combineActions +} = window.ReduxActions; + +const reducer = handleActions({ + [combineActions(increment, decrement)](state, { payload: { amount } }) { + return { ...state, counter: state.counter + amount }; + } +}, defaultState); +``` + +We have finally used all of the tools that `redux-actions` has to offer. Concluding our [vanilla tutorial](https://www.webpackbin.com/bins/-KntJIfbsxVzsD98UEWF). This doesn't mean you don't have more to learn though. Much more can be accomplished using these tools in many ways, just head on over to the [API Reference](../api) to learn even more. From fd7ac8761d2b52f8ecefa6fc8e73ff93b40d3653 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Fri, 30 Jun 2017 11:48:11 -0400 Subject: [PATCH 45/63] specify which action --- docs/introduction/BeginnerTutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction/BeginnerTutorial.md b/docs/introduction/BeginnerTutorial.md index 18789d59..078b064a 100644 --- a/docs/introduction/BeginnerTutorial.md +++ b/docs/introduction/BeginnerTutorial.md @@ -81,7 +81,7 @@ Next lets create our first action, 'increment', using `createAction`. const increment = createAction('INCREMENT'); ``` -Next we are going to handle that action with `handleAction`. We can provide it our action to let it know which action to handle. A method to handle our state transformation, and the default state. +Next we are going to handle that action with `handleAction`. We can provide it our `increment` action to let it know which action to handle. A method to handle our state transformation, and the default state. ```js const reducer = handleAction(increment, (state, action) => ({ From d9804df5e41ce8ef3b0ad5fa2ba4e79f3a018e50 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Fri, 30 Jun 2017 11:49:04 -0400 Subject: [PATCH 46/63] tweak conclusion in beginner tutorial --- docs/introduction/BeginnerTutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction/BeginnerTutorial.md b/docs/introduction/BeginnerTutorial.md index 078b064a..63b41f6b 100644 --- a/docs/introduction/BeginnerTutorial.md +++ b/docs/introduction/BeginnerTutorial.md @@ -194,4 +194,4 @@ const reducer = handleActions({ }, defaultState); ``` -We have finally used all of the tools that `redux-actions` has to offer. Concluding our [vanilla tutorial](https://www.webpackbin.com/bins/-KntJIfbsxVzsD98UEWF). This doesn't mean you don't have more to learn though. Much more can be accomplished using these tools in many ways, just head on over to the [API Reference](../api) to learn even more. +We have finally used all of the tools that `redux-actions` has to offer. Concluding our [vanilla tutorial](https://www.webpackbin.com/bins/-KntJIfbsxVzsD98UEWF). This doesn't mean you don't have more to learn though. Much more can be accomplished using these tools in many ways, just head on over to the [API Reference](../api) to begin exploring what else `redux-actions` can do for you. From a34b8468cf5e5a3a06fb1f2df90c13630e771ae4 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Fri, 30 Jun 2017 11:51:13 -0400 Subject: [PATCH 47/63] update base docs readme --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index cb0880ca..399cb47b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,9 @@ ## Table of Contents * [Read Me](/README.md) +* [API Reference](/api/README.md) * [Introduction](/docs/introduction/README.md) + * [Motivation](/docs/introduction/Motivation.md) * [Beginner Tutorial](/docs/introduction/BeginnerTutorial.md) * [External Resources](/docs/ExternalResources.md) * [Change Log](/docs/ChangeLog.md) From 098511a93208957f92e2274f8ad2e86862f23e6d Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Fri, 30 Jun 2017 11:52:35 -0400 Subject: [PATCH 48/63] fix book json repo links --- book.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book.json b/book.json index f184ae93..3df59d0c 100644 --- a/book.json +++ b/book.json @@ -4,11 +4,11 @@ "plugins": ["edit-link", "prism", "-highlight", "github", "anchorjs"], "pluginsConfig": { "edit-link": { - "base": "https://github.com/reactjs/redux/tree/master", + "base": "https://github.com/acdlite/redux-actions/tree/master", "label": "Edit This Page" }, "github": { - "url": "https://github.com/redux-saga/redux-saga/" + "url": "https://github.com/acdlite/redux-actions/" }, "sharing": { "facebook": true, From bd97907a9221a57e782c9e1e3ce91d52001b9f68 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sat, 1 Jul 2017 15:49:15 -0400 Subject: [PATCH 49/63] rename beginner tutorial --- SUMMARY.md | 2 +- docs/README.md | 2 +- docs/introduction/README.md | 2 +- docs/introduction/{BeginnerTutorial.md => Tutorial.md} | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename docs/introduction/{BeginnerTutorial.md => Tutorial.md} (99%) diff --git a/SUMMARY.md b/SUMMARY.md index ff6a8347..a99e7e3b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -3,7 +3,7 @@ * [Read Me](/README.md) * [1. Introduction](/docs/introduction/README.md) * [1.1 Motivation](docs/introduction/Motivation.md) - * [1.2 Beginner Tutorial](/docs/introduction/BeginnerTutorial.md) + * [1.2 Beginner Tutorial](/docs/introduction/Tutorial.md) * [2. API Reference](/docs/api/README.md) * [3. Middleware](/docs/middleware/README.md) * [4. External Resources](/docs/ExternalResources.md) diff --git a/docs/README.md b/docs/README.md index 399cb47b..9b503542 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,6 +4,6 @@ * [API Reference](/api/README.md) * [Introduction](/docs/introduction/README.md) * [Motivation](/docs/introduction/Motivation.md) - * [Beginner Tutorial](/docs/introduction/BeginnerTutorial.md) + * [Beginner Tutorial](/docs/introduction/Tutorial.md) * [External Resources](/docs/ExternalResources.md) * [Change Log](/docs/ChangeLog.md) diff --git a/docs/introduction/README.md b/docs/introduction/README.md index baa35f7b..826c4f31 100644 --- a/docs/introduction/README.md +++ b/docs/introduction/README.md @@ -1,4 +1,4 @@ ## Introduction * [Motivation](/docs/introduction/motivation) -* [Beginner Tutorial](/docs/introduction/BeginnerTutorial.md) +* [Beginner Tutorial](/docs/introduction/Tutorial.md) diff --git a/docs/introduction/BeginnerTutorial.md b/docs/introduction/Tutorial.md similarity index 99% rename from docs/introduction/BeginnerTutorial.md rename to docs/introduction/Tutorial.md index 63b41f6b..360ed61a 100644 --- a/docs/introduction/BeginnerTutorial.md +++ b/docs/introduction/Tutorial.md @@ -1,4 +1,4 @@ -## Beginner Tutorial +## Tutorial ### Installation From db47601fb0a3fee2bc2f9f966153d405fb623065 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sat, 1 Jul 2017 16:00:53 -0400 Subject: [PATCH 50/63] add undefined identity function back to api ref --- docs/api/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/api/README.md b/docs/api/README.md index 1b84a8c3..529d1a12 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -181,7 +181,8 @@ const actionCreators = createActions({ amount => ({ amount }), amount => ({ key: 'value', amount }) ], - DECREMENT: amount => ({ amount: -amount }) + DECREMENT: amount => ({ amount: -amount }), + SET: undefined // given undefined, the identity function will be used }, NOTIFY: [ (username, message) => ({ message: `${username}: ${message}` }), @@ -199,6 +200,10 @@ expect(actionCreators.app.counter.decrement(1)).to.deep.equal({ type: 'APP/COUNTER/DECREMENT', payload: { amount: -1 } }); +expect(actionCreators.app.counter.set(100)).to.deep.equal({ + type: 'APP/COUNTER/SET', + payload: 100 +}); expect(actionCreators.app.notify('yangmillstheory', 'Hello World')).to.deep.equal({ type: 'APP/NOTIFY', payload: { message: 'yangmillstheory: Hello World' }, From ff973e26e5329c57cde7b109cb6340a59156a73a Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sat, 1 Jul 2017 16:10:41 -0400 Subject: [PATCH 51/63] rename tutorial title, missed a few --- SUMMARY.md | 2 +- docs/README.md | 2 +- docs/introduction/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index a99e7e3b..eea2a381 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -3,7 +3,7 @@ * [Read Me](/README.md) * [1. Introduction](/docs/introduction/README.md) * [1.1 Motivation](docs/introduction/Motivation.md) - * [1.2 Beginner Tutorial](/docs/introduction/Tutorial.md) + * [1.2 Tutorial](/docs/introduction/Tutorial.md) * [2. API Reference](/docs/api/README.md) * [3. Middleware](/docs/middleware/README.md) * [4. External Resources](/docs/ExternalResources.md) diff --git a/docs/README.md b/docs/README.md index 9b503542..aa54255a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,6 +4,6 @@ * [API Reference](/api/README.md) * [Introduction](/docs/introduction/README.md) * [Motivation](/docs/introduction/Motivation.md) - * [Beginner Tutorial](/docs/introduction/Tutorial.md) + * [Tutorial](/docs/introduction/Tutorial.md) * [External Resources](/docs/ExternalResources.md) * [Change Log](/docs/ChangeLog.md) diff --git a/docs/introduction/README.md b/docs/introduction/README.md index 826c4f31..137fb35d 100644 --- a/docs/introduction/README.md +++ b/docs/introduction/README.md @@ -1,4 +1,4 @@ ## Introduction * [Motivation](/docs/introduction/motivation) -* [Beginner Tutorial](/docs/introduction/Tutorial.md) +* [Tutorial](/docs/introduction/Tutorial.md) From a8c6c1c3358beccafffe5c142fa925ee96b00464 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 01:04:43 -0400 Subject: [PATCH 52/63] add list of contributors --- README.md | 1 + SUMMARY.md | 1 + docs/Contributors.md | 38 ++++++++++++++++++++++++++++++++++++++ docs/README.md | 1 + 4 files changed, 41 insertions(+) create mode 100644 docs/Contributors.md diff --git a/README.md b/README.md index 2b89e43a..c2ba2702 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,4 @@ For more complex scenarios we recommend reading our documentation. * [Middleware](/docs/middleware) * [External Resources](/docs/ExternalResources.md) * [Change Log](/docs/ChangeLog.md) +* [Contributors](/docs/Contributors.md) diff --git a/SUMMARY.md b/SUMMARY.md index eea2a381..57947170 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -8,3 +8,4 @@ * [3. Middleware](/docs/middleware/README.md) * [4. External Resources](/docs/ExternalResources.md) * [5. Change Log](/docs/ChangeLog.md) +* [6. Contributors](/docs/Contributors.md) diff --git a/docs/Contributors.md b/docs/Contributors.md new file mode 100644 index 00000000..a7dc5eb4 --- /dev/null +++ b/docs/Contributors.md @@ -0,0 +1,38 @@ +# Contributors + +acdlite +yangmillstheory +timche +JaKXz +jaridmargolin +krisaoe +ggilberth +goto-bus-stop +ruszki +xiaohanzhang +jayphelps +crw +andrewsuzuki +nikita-graf +seniorquico +jreinert +sorrycc +nixpulvis +albertogasparin +SPARTAN563 +contra +grifotv +danny-andrews +evgenyrodionov +lukewestby +ngokevin +dbachrach +deoxxa +dbrans +johanneslumpe +ustccjw +dustyburwell +Lucretiel +webholics +JasonKid +vinnymac diff --git a/docs/README.md b/docs/README.md index aa54255a..907e157e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -7,3 +7,4 @@ * [Tutorial](/docs/introduction/Tutorial.md) * [External Resources](/docs/ExternalResources.md) * [Change Log](/docs/ChangeLog.md) +* [Contributors](/docs/Contributors.md) From 0a919912cdfbab1cd7b77940bbe4d1166513b4fe Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 02:37:25 -0400 Subject: [PATCH 53/63] break down API reference into pages --- SUMMARY.md | 3 + docs/README.md | 3 + docs/api/README.md | 394 +------------------------------------ docs/api/combineActions.md | 63 ++++++ docs/api/createAction.md | 247 +++++++++++++++++++++++ docs/api/handleAction.md | 92 +++++++++ 6 files changed, 412 insertions(+), 390 deletions(-) create mode 100644 docs/api/combineActions.md create mode 100644 docs/api/createAction.md create mode 100644 docs/api/handleAction.md diff --git a/SUMMARY.md b/SUMMARY.md index 57947170..d79666a4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -5,6 +5,9 @@ * [1.1 Motivation](docs/introduction/Motivation.md) * [1.2 Tutorial](/docs/introduction/Tutorial.md) * [2. API Reference](/docs/api/README.md) + * [2.1 createAction(s)](/docs/api/createAction.md) + * [2.2 handleAction(s)](/docs/api/handleAction.md) + * [2.3 combineActions](/docs/api/combineActions.md) * [3. Middleware](/docs/middleware/README.md) * [4. External Resources](/docs/ExternalResources.md) * [5. Change Log](/docs/ChangeLog.md) diff --git a/docs/README.md b/docs/README.md index 907e157e..92d857bd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,6 +2,9 @@ * [Read Me](/README.md) * [API Reference](/api/README.md) + * [createAction(s)](/api/createAction.md) + * [handleAction(s)](/api/handleAction.md) + * [combineActions](/api/combineActions.md) * [Introduction](/docs/introduction/README.md) * [Motivation](/docs/introduction/Motivation.md) * [Tutorial](/docs/introduction/Tutorial.md) diff --git a/docs/api/README.md b/docs/api/README.md index 529d1a12..bf62609f 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -1,392 +1,6 @@ # API Reference -* [Methods](#methods) - * [createAction](#createaction) - * [`createAction(type)`](#createactiontype) - * [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator) - * [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator) - * [createActions](#createactions) - * [`createActions(actionMap)`](#createactionsactionmap) - * [`createActions(actionMap, ...identityActions)`](#createactionsactionmap-identityactions) - * [handleAction](#handleaction) - * [`handleAction(type, reducer, defaultState)`](#handleactiontype-reducer-defaultstate) - * [`handleAction(type, reducerMap, defaultState)`](#handleactiontype-reducermap-defaultstate) - * [handleActions](#handleactions) - * [`handleActions(reducerMap, defaultState)`](#handleactionsreducermap-defaultstate) - * [combineActions](#combineactions) - * [`combineActions(...types)`](#combineactionstypes) - -## Methods - -### createAction - -```js -createAction( - type, - payloadCreator = Identity, - ?metaCreator -) -``` - -Wraps an action creator so that its return value is the payload of a Flux Standard Action. - -```js -import { createAction } from 'redux-actions'; -``` - -**NOTE:** The more correct name for this function is probably `createActionCreator()`, but that seems a bit redundant. - -#### `createAction(type)` {#createactiontype} - -Calling `createAction` with a `type` will return an action creator for dispatching actions. `type` must implement `toString` and is the only required parameter for `createAction`. - -###### EXAMPLE - -```js -export const increment = createAction('INCREMENT') -export const decrement = createAction('DECREMENT') - -increment() // { type: 'INCREMENT' } -decrement() // { type: 'DECREMENT' } -increment(10) // { type: 'INCREMENT', payload: 10 } -decrement([1, 42]) // { type: 'DECREMENT', payload: [1, 42] } -``` - -If the payload is an instance of an [Error object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error), - `redux-actions` will automatically set `action.error` to true. - -###### EXAMPLE - -```js -const noop = createAction('NOOP'); - -const error = new TypeError('not a number'); -expect(noop(error)).to.deep.equal({ - type: 'NOOP', - payload: error, - error: true -}); -``` - -`createAction` also returns its `type` when used as type in `handleAction` or `handleActions`. - -###### EXAMPLE - -```js -const noop = createAction('INCREMENT'); - -// As parameter in handleAction: -handleAction(noop, { - next(state, action) {...}, - throw(state, action) {...} -}); - -// As object key in handleActions: -const reducer = handleActions({ - [noop]: (state, action) => ({ - counter: state.counter + action.payload - }) -}, { counter: 0 }); -``` - -Use the identity form to create one-off actions. - -###### EXAMPLE - -```js -createAction('ADD_TODO')('Use Redux'); -``` - -#### `createAction(type, payloadCreator)` {#createactiontype-payloadcreator} - -`payloadCreator` must be a function, `undefined`, or `null`. If `payloadCreator` is `undefined` or `null`, the identity function is used. - -###### EXAMPLE - -```js -let noop = createAction('NOOP', amount => amount); -// same as -noop = createAction('NOOP'); - -expect(noop(42)).to.deep.equal({ - type: 'NOOP', - payload: 42 -}); -``` - - -#### `createAction(type, payloadCreator, metaCreator)` {#createactiontype-payloadcreator-metacreator} - -`metaCreator` is an optional function that creates metadata for the payload. It receives the same arguments as the payload creator, but its result becomes the meta field of the resulting action. If `metaCreator` is undefined or not a function, the meta field is omitted. - -###### EXAMPLE - -```js -const updateAdminUser = createAction('UPDATE_ADMIN_USER', - (updates) => updates, - () => ({ admin: true }) -) - -updateAdminUser({ name: 'Foo' }) -// { -// type: 'UPDATE_ADMIN_USER', -// payload: { name: 'Foo' }, -// meta: { admin: true }, -// } -``` - -### createActions - -```js -createActions( - actionMap, - ?...identityActions, -) -``` - -Returns an object mapping action types to action creators. The keys of this object are camel-cased from the keys in `actionMap` and the string literals of `identityActions`; the values are the action creators. - -```js -import { createActions } from 'redux-actions'; -``` - -#### `createActions(actionMap)` {#createactionsactionmap} - -`actionMap` is an object which can optionally have a recursive data structure, with action types as keys, and whose values **must** be either - -* a function, which is the payload creator for that action -* an array with `payload` and `meta` functions in that order, as in [`createAction`](#createaction) - * `meta` is **required** in this case \(otherwise use the function form above\) -* an `actionMap` - -###### EXAMPLE -```js -createActions({ - ADD_TODO: todo => ({ todo }) // payload creator, - REMOVE_TODO: [ - todo => ({ todo }), // payload creator - (todo, warn) => ({ todo, warn }) // meta - ] -}); -``` - -If `actionMap` has a recursive structure, its leaves are used as payload and meta creators, and the action type for each leaf is the combined path to that leaf: - -###### EXAMPLE -```js -const actionCreators = createActions({ - APP: { - COUNTER: { - INCREMENT: [ - amount => ({ amount }), - amount => ({ key: 'value', amount }) - ], - DECREMENT: amount => ({ amount: -amount }), - SET: undefined // given undefined, the identity function will be used - }, - NOTIFY: [ - (username, message) => ({ message: `${username}: ${message}` }), - (username, message) => ({ username, message }) - ] - } -}); - -expect(actionCreators.app.counter.increment(1)).to.deep.equal({ - type: 'APP/COUNTER/INCREMENT', - payload: { amount: 1 }, - meta: { key: 'value', amount: 1 } -}); -expect(actionCreators.app.counter.decrement(1)).to.deep.equal({ - type: 'APP/COUNTER/DECREMENT', - payload: { amount: -1 } -}); -expect(actionCreators.app.counter.set(100)).to.deep.equal({ - type: 'APP/COUNTER/SET', - payload: 100 -}); -expect(actionCreators.app.notify('yangmillstheory', 'Hello World')).to.deep.equal({ - type: 'APP/NOTIFY', - payload: { message: 'yangmillstheory: Hello World' }, - meta: { username: 'yangmillstheory', message: 'Hello World' } -}); -``` - -When using this form, you can pass an object with key `namespace` as the last positional argument, instead of the default `/`. - -###### EXAMPLE -```js -createActions({ ... }, 'INCREMENT', { namespace: '--' }) -``` - -#### `createActions(actionMap, ...identityActions)`{#createactionsactionmap-identityactions} - -`identityActions` is an optional list of positional string arguments that are action type strings; these action types will use the identity payload creator. - -```js -const { actionOne, actionTwo, actionThree } = createActions({ - // function form; payload creator defined inline - ACTION_ONE: (key, value) => ({ [key]: value }), - - // array form - ACTION_TWO: [ - (first) => [first], // payload - (first, second) => ({ second }) // meta - ], - - // trailing action type string form; payload creator is the identity -}, 'ACTION_THREE'); - -expect(actionOne('key', 1)).to.deep.equal({ - type: 'ACTION_ONE', - payload: { key: 1 } -}); - -expect(actionTwo('first', 'second')).to.deep.equal({ - type: 'ACTION_TWO', - payload: ['first'], - meta: { second: 'second' } -}); - -expect(actionThree(3)).to.deep.equal({ - type: 'ACTION_THREE', - payload: 3, -}); -``` - -### handleAction - -```js -handleAction( - type, - reducer | reducerMap = Identity, - defaultState, -) -``` - -Wraps a reducer so that it only handles Flux Standard Actions of a certain type. - -```js -import { handleAction } from 'redux-actions'; -``` - -#### `handleAction(type, reducer, defaultState)`{#handleactiontype-reducer-defaultstate} - -If a `reducer` function is passed, it is used to handle both normal actions and failed actions. (A failed action is analogous to a rejected promise.) You can use this form if you know a certain type of action will never fail, like the increment example above. - -If the reducer argument (`reducer`) is `undefined`, then the identity function is used. - -The third parameter `defaultState` is required, and is used when `undefined` is passed to the reducer. - -###### EXAMPLE -```js -handleAction('APP/COUNTER/INCREMENT', (state, action) => ({ - counter: state.counter + action.payload.amount, -}), defaultState); -``` - -#### `handleAction(type, reducerMap, defaultState)`{#handleactiontype-reducermap-defaultstate} - -Otherwise, you can specify separate reducers for `next()` and `throw()` using the `reducerMap` form. This API is inspired by the ES6 generator interface. - -If the reducer argument (`reducerMap`) is `undefined`, then the identity function is used. - -###### EXAMPLE -```js -handleAction('FETCH_DATA', { - next(state, action) {...}, - throw(state, action) {...}, -}, defaultState); -``` - -If either `next()` or `throw()` are `undefined` or `null`, then the identity function is used for that reducer. - -### handleActions - -```js -handleActions( - reducerMap, - defaultState, -) -``` - -Creates multiple reducers using `handleAction()` and combines them into a single reducer that handles multiple actions. Accepts a map where the keys are passed as the first parameter to `handleAction()` (the action type), and the values are passed as the second parameter (either a reducer or reducer map). The map must not be empty. - -```js -import { handleActions } from 'redux-actions'; -``` - -#### `handleActions(reducerMap, defaultState)` {#handleactionsreducermap-defaultstate} - -The second parameter `defaultState` is required, and is used when `undefined` is passed to the reducer. - -(Internally, `handleActions()` works by applying multiple reducers in sequence using [reduce-reducers](https://github.com/acdlite/reduce-reducers).) - -###### EXAMPLE - -```js -const reducer = handleActions({ - INCREMENT: (state, action) => ({ - counter: state.counter + action.payload - }), - - DECREMENT: (state, action) => ({ - counter: state.counter - action.payload - }) -}, { counter: 0 }); -``` - -### combineActions - -```js -combineActions( - ...types, -) -``` - -Combine any number of action types or action creators. `types` is a list of positional arguments which can be action type strings, symbols, or action creators. - -```js -import { combineActions } from 'redux-actions'; -``` - -#### `combineActions(...types)` {#combineactionstypes} - -This allows you to reduce multiple distinct actions with the same reducer. - -```js -const { increment, decrement } = createActions({ - INCREMENT: amount => ({ amount }), - DECREMENT: amount => ({ amount: -amount }), -}) - -const reducer = handleAction(combineActions(increment, decrement), { - next: (state, { payload: { amount } }) => ({ ...state, counter: state.counter + amount }), - throw: state => ({ ...state, counter: 0 }), -}, { counter: 10 }) - -expect(reducer(undefined, increment(1)).to.deep.equal({ counter: 11 }) -expect(reducer(undefined, decrement(1)).to.deep.equal({ counter: 9 }) -expect(reducer(undefined, increment(new Error)).to.deep.equal({ counter: 0 }) -expect(reducer(undefined, decrement(new Error)).to.deep.equal({ counter: 0 }) -``` - -Below is how you would use `combineActions` and `handleActions` together - -###### EXAMPLE -```js -const { increment, decrement } = createActions({ - INCREMENT: amount => ({ amount }), - DECREMENT: amount => ({ amount: -amount }) -}); - -const reducer = handleActions({ - [combineActions(increment, decrement)](state, { payload: { amount } }) { - return { ...state, counter: state.counter + amount }; - } -}, { counter: 10 }); - -expect(reducer({ counter: 5 }, increment(5))).to.deep.equal({ counter: 10 }); -expect(reducer({ counter: 5 }, decrement(5))).to.deep.equal({ counter: 0 }); -expect(reducer({ counter: 5 }, { type: 'NOT_TYPE', payload: 1000 })).to.equal({ counter: 5 }); -expect(reducer(undefined, increment(5))).to.deep.equal({ counter: 15 }); -``` +* Methods + * [createAction(s)](./createAction.md) + * [handleAction(s)](./handleAction.md) + * [combineActions](./combineActions.md) diff --git a/docs/api/combineActions.md b/docs/api/combineActions.md new file mode 100644 index 00000000..c70f3ad1 --- /dev/null +++ b/docs/api/combineActions.md @@ -0,0 +1,63 @@ +# combineActions + +* [Methods](#methods) + * [combineActions](#combineactions) + * [`combineActions(...types)`](#combineactionstypes) + +## Methods + +### combineActions + +```js +combineActions( + ...types, +) +``` + +Combine any number of action types or action creators. `types` is a list of positional arguments which can be action type strings, symbols, or action creators. + +```js +import { combineActions } from 'redux-actions'; +``` + +#### `combineActions(...types)` {#combineactionstypes} + +This allows you to reduce multiple distinct actions with the same reducer. + +```js +const { increment, decrement } = createActions({ + INCREMENT: amount => ({ amount }), + DECREMENT: amount => ({ amount: -amount }), +}) + +const reducer = handleAction(combineActions(increment, decrement), { + next: (state, { payload: { amount } }) => ({ ...state, counter: state.counter + amount }), + throw: state => ({ ...state, counter: 0 }), +}, { counter: 10 }) + +expect(reducer(undefined, increment(1)).to.deep.equal({ counter: 11 }) +expect(reducer(undefined, decrement(1)).to.deep.equal({ counter: 9 }) +expect(reducer(undefined, increment(new Error)).to.deep.equal({ counter: 0 }) +expect(reducer(undefined, decrement(new Error)).to.deep.equal({ counter: 0 }) +``` + +Below is how you would use `combineActions` and `handleActions` together + +###### EXAMPLE +```js +const { increment, decrement } = createActions({ + INCREMENT: amount => ({ amount }), + DECREMENT: amount => ({ amount: -amount }) +}); + +const reducer = handleActions({ + [combineActions(increment, decrement)](state, { payload: { amount } }) { + return { ...state, counter: state.counter + amount }; + } +}, { counter: 10 }); + +expect(reducer({ counter: 5 }, increment(5))).to.deep.equal({ counter: 10 }); +expect(reducer({ counter: 5 }, decrement(5))).to.deep.equal({ counter: 0 }); +expect(reducer({ counter: 5 }, { type: 'NOT_TYPE', payload: 1000 })).to.equal({ counter: 5 }); +expect(reducer(undefined, increment(5))).to.deep.equal({ counter: 15 }); +``` diff --git a/docs/api/createAction.md b/docs/api/createAction.md new file mode 100644 index 00000000..3c7e10ac --- /dev/null +++ b/docs/api/createAction.md @@ -0,0 +1,247 @@ +# createAction(s) + +* [Methods](#methods) + * [createAction](#createaction) + * [`createAction(type)`](#createactiontype) + * [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator) + * [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator) + * [createActions](#createactions) + * [`createActions(actionMap)`](#createactionsactionmap) + * [`createActions(actionMap, ...identityActions)`](#createactionsactionmap-identityactions) + +## Methods + +### createAction + +```js +createAction( + type, + payloadCreator = Identity, + ?metaCreator +) +``` + +Wraps an action creator so that its return value is the payload of a Flux Standard Action. + +```js +import { createAction } from 'redux-actions'; +``` + +**NOTE:** The more correct name for this function is probably `createActionCreator()`, but that seems a bit redundant. + +#### `createAction(type)` {#createactiontype} + +Calling `createAction` with a `type` will return an action creator for dispatching actions. `type` must implement `toString` and is the only required parameter for `createAction`. + +###### EXAMPLE + +```js +export const increment = createAction('INCREMENT') +export const decrement = createAction('DECREMENT') + +increment() // { type: 'INCREMENT' } +decrement() // { type: 'DECREMENT' } +increment(10) // { type: 'INCREMENT', payload: 10 } +decrement([1, 42]) // { type: 'DECREMENT', payload: [1, 42] } +``` + +If the payload is an instance of an [Error object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error), + `redux-actions` will automatically set `action.error` to true. + +###### EXAMPLE + +```js +const noop = createAction('NOOP'); + +const error = new TypeError('not a number'); +expect(noop(error)).to.deep.equal({ + type: 'NOOP', + payload: error, + error: true +}); +``` + +`createAction` also returns its `type` when used as type in `handleAction` or `handleActions`. + +###### EXAMPLE + +```js +const noop = createAction('INCREMENT'); + +// As parameter in handleAction: +handleAction(noop, { + next(state, action) {...}, + throw(state, action) {...} +}); + +// As object key in handleActions: +const reducer = handleActions({ + [noop]: (state, action) => ({ + counter: state.counter + action.payload + }) +}, { counter: 0 }); +``` + +Use the identity form to create one-off actions. + +###### EXAMPLE + +```js +createAction('ADD_TODO')('Use Redux'); +``` + +#### `createAction(type, payloadCreator)` {#createactiontype-payloadcreator} + +`payloadCreator` must be a function, `undefined`, or `null`. If `payloadCreator` is `undefined` or `null`, the identity function is used. + +###### EXAMPLE + +```js +let noop = createAction('NOOP', amount => amount); +// same as +noop = createAction('NOOP'); + +expect(noop(42)).to.deep.equal({ + type: 'NOOP', + payload: 42 +}); +``` + + +#### `createAction(type, payloadCreator, metaCreator)` {#createactiontype-payloadcreator-metacreator} + +`metaCreator` is an optional function that creates metadata for the payload. It receives the same arguments as the payload creator, but its result becomes the meta field of the resulting action. If `metaCreator` is undefined or not a function, the meta field is omitted. + +###### EXAMPLE + +```js +const updateAdminUser = createAction('UPDATE_ADMIN_USER', + (updates) => updates, + () => ({ admin: true }) +) + +updateAdminUser({ name: 'Foo' }) +// { +// type: 'UPDATE_ADMIN_USER', +// payload: { name: 'Foo' }, +// meta: { admin: true }, +// } +``` + +### createActions + +```js +createActions( + actionMap, + ?...identityActions, +) +``` + +Returns an object mapping action types to action creators. The keys of this object are camel-cased from the keys in `actionMap` and the string literals of `identityActions`; the values are the action creators. + +```js +import { createActions } from 'redux-actions'; +``` + +#### `createActions(actionMap)` {#createactionsactionmap} + +`actionMap` is an object which can optionally have a recursive data structure, with action types as keys, and whose values **must** be either + +* a function, which is the payload creator for that action +* an array with `payload` and `meta` functions in that order, as in [`createAction`](#createaction) + * `meta` is **required** in this case \(otherwise use the function form above\) +* an `actionMap` + +###### EXAMPLE +```js +createActions({ + ADD_TODO: todo => ({ todo }) // payload creator, + REMOVE_TODO: [ + todo => ({ todo }), // payload creator + (todo, warn) => ({ todo, warn }) // meta + ] +}); +``` + +If `actionMap` has a recursive structure, its leaves are used as payload and meta creators, and the action type for each leaf is the combined path to that leaf: + +###### EXAMPLE +```js +const actionCreators = createActions({ + APP: { + COUNTER: { + INCREMENT: [ + amount => ({ amount }), + amount => ({ key: 'value', amount }) + ], + DECREMENT: amount => ({ amount: -amount }), + SET: undefined // given undefined, the identity function will be used + }, + NOTIFY: [ + (username, message) => ({ message: `${username}: ${message}` }), + (username, message) => ({ username, message }) + ] + } +}); + +expect(actionCreators.app.counter.increment(1)).to.deep.equal({ + type: 'APP/COUNTER/INCREMENT', + payload: { amount: 1 }, + meta: { key: 'value', amount: 1 } +}); +expect(actionCreators.app.counter.decrement(1)).to.deep.equal({ + type: 'APP/COUNTER/DECREMENT', + payload: { amount: -1 } +}); +expect(actionCreators.app.counter.set(100)).to.deep.equal({ + type: 'APP/COUNTER/SET', + payload: 100 +}); +expect(actionCreators.app.notify('yangmillstheory', 'Hello World')).to.deep.equal({ + type: 'APP/NOTIFY', + payload: { message: 'yangmillstheory: Hello World' }, + meta: { username: 'yangmillstheory', message: 'Hello World' } +}); +``` + +When using this form, you can pass an object with key `namespace` as the last positional argument, instead of the default `/`. + +###### EXAMPLE +```js +createActions({ ... }, 'INCREMENT', { namespace: '--' }) +``` + +#### `createActions(actionMap, ...identityActions)`{#createactionsactionmap-identityactions} + +`identityActions` is an optional list of positional string arguments that are action type strings; these action types will use the identity payload creator. + +```js +const { actionOne, actionTwo, actionThree } = createActions({ + // function form; payload creator defined inline + ACTION_ONE: (key, value) => ({ [key]: value }), + + // array form + ACTION_TWO: [ + (first) => [first], // payload + (first, second) => ({ second }) // meta + ], + + // trailing action type string form; payload creator is the identity +}, 'ACTION_THREE'); + +expect(actionOne('key', 1)).to.deep.equal({ + type: 'ACTION_ONE', + payload: { key: 1 } +}); + +expect(actionTwo('first', 'second')).to.deep.equal({ + type: 'ACTION_TWO', + payload: ['first'], + meta: { second: 'second' } +}); + +expect(actionThree(3)).to.deep.equal({ + type: 'ACTION_THREE', + payload: 3, +}); +``` diff --git a/docs/api/handleAction.md b/docs/api/handleAction.md new file mode 100644 index 00000000..1f31bbdf --- /dev/null +++ b/docs/api/handleAction.md @@ -0,0 +1,92 @@ +# handleAction(s) + +* [Methods](#methods) + * [handleAction](#handleaction) + * [`handleAction(type, reducer, defaultState)`](#handleactiontype-reducer-defaultstate) + * [`handleAction(type, reducerMap, defaultState)`](#handleactiontype-reducermap-defaultstate) + * [handleActions](#handleactions) + * [`handleActions(reducerMap, defaultState)`](#handleactionsreducermap-defaultstate) + +## Methods + +### handleAction + +```js +handleAction( + type, + reducer | reducerMap = Identity, + defaultState, +) +``` + +Wraps a reducer so that it only handles Flux Standard Actions of a certain type. + +```js +import { handleAction } from 'redux-actions'; +``` + +#### `handleAction(type, reducer, defaultState)`{#handleactiontype-reducer-defaultstate} + +If a `reducer` function is passed, it is used to handle both normal actions and failed actions. (A failed action is analogous to a rejected promise.) You can use this form if you know a certain type of action will never fail, like the increment example above. + +If the reducer argument (`reducer`) is `undefined`, then the identity function is used. + +The third parameter `defaultState` is required, and is used when `undefined` is passed to the reducer. + +###### EXAMPLE +```js +handleAction('APP/COUNTER/INCREMENT', (state, action) => ({ + counter: state.counter + action.payload.amount, +}), defaultState); +``` + +#### `handleAction(type, reducerMap, defaultState)`{#handleactiontype-reducermap-defaultstate} + +Otherwise, you can specify separate reducers for `next()` and `throw()` using the `reducerMap` form. This API is inspired by the ES6 generator interface. + +If the reducer argument (`reducerMap`) is `undefined`, then the identity function is used. + +###### EXAMPLE +```js +handleAction('FETCH_DATA', { + next(state, action) {...}, + throw(state, action) {...}, +}, defaultState); +``` + +If either `next()` or `throw()` are `undefined` or `null`, then the identity function is used for that reducer. + +### handleActions + +```js +handleActions( + reducerMap, + defaultState, +) +``` + +Creates multiple reducers using `handleAction()` and combines them into a single reducer that handles multiple actions. Accepts a map where the keys are passed as the first parameter to `handleAction()` (the action type), and the values are passed as the second parameter (either a reducer or reducer map). The map must not be empty. + +```js +import { handleActions } from 'redux-actions'; +``` + +#### `handleActions(reducerMap, defaultState)` {#handleactionsreducermap-defaultstate} + +The second parameter `defaultState` is required, and is used when `undefined` is passed to the reducer. + +(Internally, `handleActions()` works by applying multiple reducers in sequence using [reduce-reducers](https://github.com/acdlite/reduce-reducers).) + +###### EXAMPLE + +```js +const reducer = handleActions({ + INCREMENT: (state, action) => ({ + counter: state.counter + action.payload + }), + + DECREMENT: (state, action) => ({ + counter: state.counter - action.payload + }) +}, { counter: 0 }); +``` From 5c923874270a562b73ee0b80093f3b0f3501de58 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 02:40:36 -0400 Subject: [PATCH 54/63] make contributors a list --- docs/Contributors.md | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/Contributors.md b/docs/Contributors.md index a7dc5eb4..d8437f96 100644 --- a/docs/Contributors.md +++ b/docs/Contributors.md @@ -1,38 +1,38 @@ # Contributors -acdlite -yangmillstheory -timche -JaKXz -jaridmargolin -krisaoe -ggilberth -goto-bus-stop -ruszki -xiaohanzhang -jayphelps -crw -andrewsuzuki -nikita-graf -seniorquico -jreinert -sorrycc -nixpulvis -albertogasparin -SPARTAN563 -contra -grifotv -danny-andrews -evgenyrodionov -lukewestby -ngokevin -dbachrach -deoxxa -dbrans -johanneslumpe -ustccjw -dustyburwell -Lucretiel -webholics -JasonKid -vinnymac +* acdlite +* yangmillstheory +* timche +* JaKXz +* jaridmargolin +* krisaoe +* ggilberth +* goto-bus-stop +* ruszki +* xiaohanzhang +* jayphelps +* crw +* andrewsuzuki +* nikita-graf +* seniorquico +* jreinert +* sorrycc +* nixpulvis +* albertogasparin +* SPARTAN563 +* contra +* grifotv +* danny-andrews +* evgenyrodionov +* lukewestby +* ngokevin +* dbachrach +* deoxxa +* dbrans +* johanneslumpe +* ustccjw +* dustyburwell +* Lucretiel +* webholics +* JasonKid +* vinnymac From ebc39a2f87dac7a89e56b21793fce3cc8f52ec85 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 09:56:16 -0400 Subject: [PATCH 55/63] aesthetics for docs link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c2ba2702..b537dfa7 100644 --- a/README.md +++ b/README.md @@ -52,9 +52,9 @@ const reducer = handleActions({ export default reducer; ``` -For more complex scenarios we recommend reading our documentation. +For more complex scenarios we recommend reading our [documentation](https://vinnymac.gitbooks.io/redux-actions/content/). -# [Documentation](https://vinnymac.gitbooks.io/redux-actions/content/) +# Documentation * [Introduction](/docs/introduction) * [API](/docs/api) From 610dc17ff0d7bc18886a45c709818c11a8dee8a2 Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 11:14:51 -0400 Subject: [PATCH 56/63] change method page headers --- docs/api/combineActions.md | 2 +- docs/api/createAction.md | 2 +- docs/api/handleAction.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/combineActions.md b/docs/api/combineActions.md index c70f3ad1..98ea7937 100644 --- a/docs/api/combineActions.md +++ b/docs/api/combineActions.md @@ -1,4 +1,4 @@ -# combineActions +# API Reference for combineActions * [Methods](#methods) * [combineActions](#combineactions) diff --git a/docs/api/createAction.md b/docs/api/createAction.md index 3c7e10ac..0a6e96a4 100644 --- a/docs/api/createAction.md +++ b/docs/api/createAction.md @@ -1,4 +1,4 @@ -# createAction(s) +# API Reference for createAction(s) * [Methods](#methods) * [createAction](#createaction) diff --git a/docs/api/handleAction.md b/docs/api/handleAction.md index 1f31bbdf..23996b8d 100644 --- a/docs/api/handleAction.md +++ b/docs/api/handleAction.md @@ -1,4 +1,4 @@ -# handleAction(s) +# API Reference for handleAction(s) * [Methods](#methods) * [handleAction](#handleaction) From 6251467eed8c661158895618b4074450f51167ee Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 20:23:54 -0400 Subject: [PATCH 57/63] restore changes to createAction docs --- docs/api/createAction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/createAction.md b/docs/api/createAction.md index 0a6e96a4..5148093d 100644 --- a/docs/api/createAction.md +++ b/docs/api/createAction.md @@ -204,7 +204,7 @@ expect(actionCreators.app.notify('yangmillstheory', 'Hello World')).to.deep.equa }); ``` -When using this form, you can pass an object with key `namespace` as the last positional argument, instead of the default `/`. +When using this form, you can pass an object with key `namespace` as the last positional argument (the default is `/`). ###### EXAMPLE ```js From 1148cebbf96ff412a5cdac21003fa9adc8df644c Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 20:24:04 -0400 Subject: [PATCH 58/63] restore changes to handleActions docs --- docs/api/handleAction.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api/handleAction.md b/docs/api/handleAction.md index 23996b8d..a1be6e4e 100644 --- a/docs/api/handleAction.md +++ b/docs/api/handleAction.md @@ -67,6 +67,8 @@ handleActions( Creates multiple reducers using `handleAction()` and combines them into a single reducer that handles multiple actions. Accepts a map where the keys are passed as the first parameter to `handleAction()` (the action type), and the values are passed as the second parameter (either a reducer or reducer map). The map must not be empty. +If `reducerMap` has a recursive structure, its leaves are used as reducers, and the action type for each leaf is the path to that leaf. If a node's only children are `next()` and `throw()`, the node will be treated as a reducer. If the leaf is `undefined` or `null`, the identity function is used as the reducer. Otherwise, the leaf should be the reducer function. When using this form, you can pass an object with key `namespace` as the last positional argument (the default is `/`). + ```js import { handleActions } from 'redux-actions'; ``` From 6d12354d28f265a44a7b03dab0a8fe1921a84ada Mon Sep 17 00:00:00 2001 From: Victor Alvarez Date: Sun, 2 Jul 2017 19:52:35 -0700 Subject: [PATCH 59/63] use github handles --- docs/Contributors.md | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/Contributors.md b/docs/Contributors.md index d8437f96..9d4d8d33 100644 --- a/docs/Contributors.md +++ b/docs/Contributors.md @@ -1,38 +1,38 @@ # Contributors -* acdlite -* yangmillstheory -* timche -* JaKXz -* jaridmargolin -* krisaoe -* ggilberth -* goto-bus-stop -* ruszki -* xiaohanzhang -* jayphelps -* crw -* andrewsuzuki -* nikita-graf -* seniorquico -* jreinert -* sorrycc -* nixpulvis -* albertogasparin -* SPARTAN563 -* contra -* grifotv -* danny-andrews -* evgenyrodionov -* lukewestby -* ngokevin -* dbachrach -* deoxxa -* dbrans -* johanneslumpe -* ustccjw -* dustyburwell -* Lucretiel -* webholics -* JasonKid -* vinnymac +* @acdlite +* @yangmillstheory +* @timche +* @JaKXz +* @jaridmargolin +* @krisaoe +* @ggilberth +* @goto-bus-stop +* @ruszki +* @xiaohanzhang +* @jayphelps +* @crw +* @andrewsuzuki +* @nikita-graf +* @seniorquico +* @jreinert +* @sorrycc +* @nixpulvis +* @albertogasparin +* @SPARTAN563 +* @contra +* @grifotv +* @danny-andrews +* @evgenyrodionov +* @lukewestby +* @ngokevin +* @dbachrach +* @deoxxa +* @dbrans +* @johanneslumpe +* @ustccjw +* @dustyburwell +* @Lucretiel +* @webholics +* @JasonKid +* @vinnymac From 2d4a57bceaecfbc8ded2158d341abba3da988822 Mon Sep 17 00:00:00 2001 From: Victor Alvarez Date: Sun, 2 Jul 2017 20:00:02 -0700 Subject: [PATCH 60/63] use markdown links --- docs/Contributors.md | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/Contributors.md b/docs/Contributors.md index 9d4d8d33..775a426e 100644 --- a/docs/Contributors.md +++ b/docs/Contributors.md @@ -1,38 +1,38 @@ # Contributors -* @acdlite -* @yangmillstheory -* @timche -* @JaKXz -* @jaridmargolin -* @krisaoe -* @ggilberth -* @goto-bus-stop -* @ruszki -* @xiaohanzhang -* @jayphelps -* @crw -* @andrewsuzuki -* @nikita-graf -* @seniorquico -* @jreinert -* @sorrycc -* @nixpulvis -* @albertogasparin -* @SPARTAN563 -* @contra -* @grifotv -* @danny-andrews -* @evgenyrodionov -* @lukewestby -* @ngokevin -* @dbachrach -* @deoxxa -* @dbrans -* @johanneslumpe -* @ustccjw -* @dustyburwell -* @Lucretiel -* @webholics -* @JasonKid -* @vinnymac +* [acdlite](https://github.com/acdlite) +* [yangmillstheory](https://github.com/yangmillstheory) +* [timche](https://github.com/timche) +* [JaKXz](https://github.com/JaKXz) +* [jaridmargolin](https://github.com/jaridmargolin) +* [krisaoe](https://github.com/krisaoe) +* [ggilberth](https://github.com/ggilberth) +* [goto-bus-stop](https://github.com/goto-bus-stop) +* [ruszki](https://github.com/ruszki) +* [xiaohanzhang](https://github.com/xiaohanzhang) +* [jayphelps](https://github.com/jayphelps) +* [crw](https://github.com/crw) +* [andrewsuzuki](https://github.com/andrewsuzuki) +* [nikita-graf](https://github.com/nikita-graf) +* [seniorquico](https://github.com/seniorquico) +* [jreinert](https://github.com/jreinert) +* [sorrycc](https://github.com/sorrycc) +* [nixpulvis](https://github.com/nixpulvis) +* [albertogasparin](https://github.com/albertogasparin) +* [SPARTAN563](https://github.com/SPARTAN563) +* [contra](https://github.com/contra) +* [grifotv](https://github.com/grifotv) +* [danny-andrews](https://github.com/danny-andrews) +* [evgenyrodionov](https://github.com/evgenyrodionov) +* [lukewestby](https://github.com/lukewestby) +* [ngokevin](https://github.com/ngokevin) +* [dbachrach](https://github.com/dbachrach) +* [deoxxa](https://github.com/deoxxa) +* [dbrans](https://github.com/dbrans) +* [johanneslumpe](https://github.com/johanneslumpe) +* [ustccjw](https://github.com/ustccjw) +* [dustyburwell](https://github.com/dustyburwell) +* [Lucretiel](https://github.com/Lucretiel) +* [webholics](https://github.com/webholics) +* [JasonKid](https://github.com/JasonKid) +* [vinnymac](https://github.com/vinnymac) From c42a5c5ea998b5a50b01ce5599a367ef34cd3144 Mon Sep 17 00:00:00 2001 From: Victor Alvarez Date: Sun, 2 Jul 2017 20:03:51 -0700 Subject: [PATCH 61/63] link to canonical host --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b537dfa7..eaa25121 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ const reducer = handleActions({ export default reducer; ``` -For more complex scenarios we recommend reading our [documentation](https://vinnymac.gitbooks.io/redux-actions/content/). +For more complex scenarios we recommend reading our [documentation](https://redux-actions.js.org/). # Documentation From f3bfe59c1728009b8634b0a80cf55babec6dfe3f Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 23:34:23 -0400 Subject: [PATCH 62/63] remove unnecessary css file --- build/gitbook.css | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 build/gitbook.css diff --git a/build/gitbook.css b/build/gitbook.css deleted file mode 100644 index 7d1b01a9..00000000 --- a/build/gitbook.css +++ /dev/null @@ -1,3 +0,0 @@ -.token.operator { - background: none; -} From ad85743571716f4401b86af64293210009e683fc Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Sun, 2 Jul 2017 23:37:38 -0400 Subject: [PATCH 63/63] remove default theme config --- book.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/book.json b/book.json index 3df59d0c..f77b8eb3 100644 --- a/book.json +++ b/book.json @@ -17,11 +17,6 @@ "weibo": false, "instapaper": false, "vk": false - }, - "theme-default": { - "styles": { - "website": "build/gitbook.css" - } } } }