Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guillaumearm/redux-custom-middlewares
middlewares inside your FSA actions
https://github.com/guillaumearm/redux-custom-middlewares
Last synced: 5 days ago
JSON representation
middlewares inside your FSA actions
- Host: GitHub
- URL: https://github.com/guillaumearm/redux-custom-middlewares
- Owner: guillaumearm
- License: mit
- Created: 2016-11-28T18:48:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-11T21:08:47.000Z (about 8 years ago)
- Last Synced: 2024-12-10T18:04:36.943Z (12 days ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-custom-middlewares
middlewares inside your [FSA actions](https://github.com/acdlite/flux-standard-action)
## Motivations
`redux-custom-middlewares` allow you to dispatch middlewares inside your FSA actions.
it's like super [thunk](https://github.com/gaearon/redux-thunk) !## Goals
- dispatch plain object actions which handle side effects
- have a contextual use of middlewares
- create redux modules## Installation
```
npm install --save redux-custom-middlewares
``````js
import { createStore, applyMiddleware } from 'redux';
import { installCustomMiddlewares } from 'redux-custom-middlewares';
import rootReducer from './reducers';
const initialState = {};const store = createStore(rootReducer, initialState applyMiddleware(installCustomMiddlewares()))
```## Usage
```js
import { customMiddleware } from 'redux-custom-middlewares';// this custom middleware just console.log the current action
const withLoggerMiddleware = customMiddleware(
() => next => action => {
console.log(action);
return next(action);
};
);const myActionCreator = withLoggerMiddleware((param) => ({
type: 'MY_ACTION',
payload: param,
}));
```## Contributing
If you like this module, you're welcome for contributing,
take a look at [CONTRIBUTING.md](https://github.com/guillaumearm/redux-custom-middlewares/blob/master/CONTRIBUTING.md)