Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

prosciutto

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosciutto

Functor based redux side effects

latest
Source
npmnpm
Version
2.1.1
Version published
Maintainers
1
Created
Source

npm PRs Welcome Open Source Love License

🥓 Prosciutto

Functor based redux side effects

Alternative to rxjs and redux-observable, or meaball

Install

yarn add prosciutto

Usage examples

Listen to any redux action, perform side effect, dispatch new redux actions

// 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))
)

Keywords

redux

FAQs

Package last updated on 24 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts