https://github.com/rametta/prosciutto
🥓 Functor based redux side effects
https://github.com/rametta/prosciutto
epics middleware promise redux side-effects
Last synced: 6 months ago
JSON representation
🥓 Functor based redux side effects
- Host: GitHub
- URL: https://github.com/rametta/prosciutto
- Owner: rametta
- License: apache-2.0
- Created: 2019-02-05T12:48:40.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T17:54:30.000Z (almost 5 years ago)
- Last Synced: 2025-04-06T10:50:27.594Z (11 months ago)
- Topics: epics, middleware, promise, redux, side-effects
- Language: JavaScript
- Homepage:
- Size: 56.6 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://npm.im/prosciutto)
[](http://makeapullrequest.com)
[](https://github.com/rametta/prosciutto/)
[](https://opensource.org/licenses/Apache-2.0)
# 🥓 Prosciutto
> [Functor](https://en.wikipedia.org/wiki/Functor) based redux side effects
*Alternative to rxjs and redux-observable, or [meaball](https://www.npmjs.com/package/meatball)*
## Install
```sh
yarn add prosciutto
```
## Usage examples
Listen to any redux action, perform side effect, dispatch new redux actions
```js
// epics.js
import { searchResponse, seachError, clearSidebar } from './reducer'
// Simple example
const simpleEpic = is => is('SUBMIT_SEARCH')
.map(({payload, store, dispatch}) => fetch(payload)
.then(res => res.json())
.then(json => dispatch(searchResponse(json)))
.catch(e => dispatch(seachError(e))))
// Dispatch multiple actions with an array
const multipleEpic = is => is('SUBMIT_SEARCH')
.map(({payload, store, dispatch}) => fetch(payload)
.then(res => res.json())
.then(json => dispatch([searchResponse(json), clearSidebar()]))
.catch(e => dispatch(seachError(e)))
)
export default [simpleEpic, multipleEpic]
// index.js
import prosciutto from 'prosciutto'
import epics from './epics'
const store = createStore(
reducers,
applyMiddleware(prosciutto(epics))
)
```