From 21d404e4ab40f0e77ab2cb93fa515fcd879837e5 Mon Sep 17 00:00:00 2001 From: Leonardo Luiz Date: Tue, 21 Mar 2017 00:07:46 -0300 Subject: [PATCH 1/2] Add handleAction example with a reducer function to README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e8c1594b..0fd03db5 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,12 @@ Wraps a reducer so that it only handles Flux Standard Actions of a certain type. 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. +```js +handleAction('INCREMENT', (state, action) => ({ + counter: state.counter + action.payload +}), defaultState); +``` + Otherwise, you can specify separate reducers for `next()` and `throw()` using the `reducerMap` form. This API is inspired by the ES6 generator interface. ```js From 88f0ed95b2eca8698fa01ea5337f8a424241d127 Mon Sep 17 00:00:00 2001 From: Leonardo Luiz Date: Tue, 21 Mar 2017 09:26:33 -0300 Subject: [PATCH 2/2] Change handleAction example with a reducer in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fd03db5..15f68f0f 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ Wraps a reducer so that it only handles Flux Standard Actions of a certain type. 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. ```js -handleAction('INCREMENT', (state, action) => ({ +const reducer = handleAction(incrementAction, (state, action) => ({ counter: state.counter + action.payload }), defaultState); ```