Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/invisible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

# Invisible Reducer 👻

An invisible reducer, we avoid repeating the same logic in each of the reducers is avoided.

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...

### 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'

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:

```js
import createReducer from '../../creators/createReducer';
import onLoading from '../../effects/onLoading';
import onSuccess from '../../effects/onSuccess';
import onFailure from '../../effects/onFailure';

const reducerDescription = {
LOADING: onLoading(),
SUCCESS: onSuccess(),
FAILURE: onFailure()
};

export const defaultActionNames = Object.keys(reducerDescription);
export default createReducer({}, reducerDescription);

```

License
----
MIT