Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rametta/prosciutto
🥓 Functor based redux side effects
https://github.com/rametta/prosciutto
epics middleware promise redux side-effects
Last synced: 16 days 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T17:54:30.000Z (almost 4 years ago)
- Last Synced: 2024-12-07T08:02:32.800Z (20 days ago)
- Topics: epics, middleware, promise, redux, side-effects
- Language: JavaScript
- Homepage:
- Size: 56.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/prosciutto.svg)](http://npm.im/prosciutto)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/rametta/prosciutto/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](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))
)
```