From 037fa639f73f7162a5a1d0142ecb316d7b750339 Mon Sep 17 00:00:00 2001 From: anaospinarojas Date: Sat, 2 Feb 2019 16:41:46 -0500 Subject: [PATCH 1/2] Readme --- src/invisible/README.md | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/invisible/README.md diff --git a/src/invisible/README.md b/src/invisible/README.md new file mode 100644 index 0000000..6e69a87 --- /dev/null +++ b/src/invisible/README.md @@ -0,0 +1,71 @@ +![coverage](https://img.shields.io/badge/Coverage-92%25-E01563.svg) ![downloads](https://img.shields.io/npm/dw/redux-recompose.svg?colorB=99d000&label=Downloads&style=popout) [![supported by](https://img.shields.io/badge/Supported%20by-Wolox.πŸ’—-blue.svg)](https://www.wolox.com.ar/) +# Invisible Reducer πŸ‘» + +By using invisible reducer, repeating the same logic in each of the reducers is avoided. + +It is a extracting your cross-reducer logic, so this logic keeps isolated and reusable by our other reducers. Also, it keeps hidden from other reducers, so πŸ‘». + +In a few words, less work... + + +### Learn Redux-recompose + +If you are not aware, we invite you to read [**Redux-recompose**](https://github.com/Wolox/redux-recompose) + +### Installation + +Dependencies: +``` +>: npm install --save redux +```` +if you already have it installed, skip this step: +``` +>: npm install --save redux-recompose +``` +we will need redux-recompose to use Invisible reducer. + +### Example +Then use it in your app, already implemented redux, we add wrapCombineReducers: +``` +import { combineReducers as CR } from 'redux'; +import { wrapCombineReducers } from 'redux-recompose' + +const combineReducers = wrapCombineReducers(CR); + +const rootReducer = combineReducers({ + // Add here your reducers as usual. +}); +``` +CombineReducers: utility from redux. This helps merge several reducers into a root one. Each reducer is part of the global state + +And that’s all, invisible in action. + +By default, redux-recompose ships with a default invisible reducer that is the following: + +``` +import createReducer from '../../creators/createReducer'; +import onLoading from '../../effects/onLoading'; +import onSuccess from '../../effects/onSuccess'; +import onFailure from '../../effects/onFailure'; + + +// TODO: Let the user specify selectors +const reducerDescription = { +LOADING: onLoading(), +SUCCESS: onSuccess(), +FAILURE: onFailure() +}; + +export const defaultActionNames = Object.keys(reducerDescription); + +// TODO: Let user specify this initialState +export default createReducer({}, reducerDescription); + +``` + + + +License +---- + +MIT From 6f16ccfd2aed7adf87bf3e151464b2cc6c32496a Mon Sep 17 00:00:00 2001 From: anaospinarojas Date: Sun, 5 May 2019 19:06:38 -0500 Subject: [PATCH 2/2] Grammatical error corrections --- src/invisible/README.md | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/invisible/README.md b/src/invisible/README.md index 6e69a87..920caf4 100644 --- a/src/invisible/README.md +++ b/src/invisible/README.md @@ -1,32 +1,15 @@ -![coverage](https://img.shields.io/badge/Coverage-92%25-E01563.svg) ![downloads](https://img.shields.io/npm/dw/redux-recompose.svg?colorB=99d000&label=Downloads&style=popout) [![supported by](https://img.shields.io/badge/Supported%20by-Wolox.πŸ’—-blue.svg)](https://www.wolox.com.ar/) + # Invisible Reducer πŸ‘» -By using invisible reducer, repeating the same logic in each of the reducers is avoided. +An invisible reducer, we avoid repeating the same logic in each of the reducers is avoided. -It is a extracting your cross-reducer logic, so this logic keeps isolated and reusable by our other reducers. Also, it keeps hidden from other reducers, so πŸ‘». +Is a extracting your cross-reducer logic, so this logic kepts isolated and reusable by our other reducers. Also, it keeps hidden from other reducers, so πŸ‘». In a few words, less work... - -### Learn Redux-recompose - -If you are not aware, we invite you to read [**Redux-recompose**](https://github.com/Wolox/redux-recompose) - -### Installation - -Dependencies: -``` ->: npm install --save redux -```` -if you already have it installed, skip this step: -``` ->: npm install --save redux-recompose -``` -we will need redux-recompose to use Invisible reducer. - ### Example Then use it in your app, already implemented redux, we add wrapCombineReducers: -``` +```js import { combineReducers as CR } from 'redux'; import { wrapCombineReducers } from 'redux-recompose' @@ -36,20 +19,18 @@ const rootReducer = combineReducers({ // Add here your reducers as usual. }); ``` -CombineReducers: utility from redux. This helps merge several reducers into a root one. Each reducer is part of the global state +CombineReducers: utility from redux. This helps merge several reducers into a root one. Each reducer is part of the global state. And that’s all, invisible in action. By default, redux-recompose ships with a default invisible reducer that is the following: -``` +```js import createReducer from '../../creators/createReducer'; import onLoading from '../../effects/onLoading'; import onSuccess from '../../effects/onSuccess'; import onFailure from '../../effects/onFailure'; - -// TODO: Let the user specify selectors const reducerDescription = { LOADING: onLoading(), SUCCESS: onSuccess(), @@ -57,15 +38,10 @@ FAILURE: onFailure() }; export const defaultActionNames = Object.keys(reducerDescription); - -// TODO: Let user specify this initialState export default createReducer({}, reducerDescription); ``` - - License ---- - MIT