Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-receive-enhancer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-receive-enhancer

A store enhancer for receiving a future redux action as a promise.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Redux Receive Enhancer

A store enhancer for receiving a future redux action as a promise.

npm i --save redux-receive-enhancer

Setup

let { createStore, compose } = require('redux')
let receiveEnhancer = require('redux-receive-enhancer')

let store = createStore(rootReducer, compose(middleware, receiveEnhancer))

Usage

store.receive({
  [actions.LOGIN_SUCCESS]: (action) => action.payload.userDetails,
  [actions.LOGIN_FAILURE]: () => Promise.reject('Login failed!')
}).then(
  takeUserToHomepage,
  showErrorAlert
)

API

receive

receive :: {type} -> Promise a b

Takes an object mapping action types to functions and returns a Promise. When an action matching one of the action types in types is dispatched, the returned promise will resolve with the result of the corresponding function (or reject if the function returns a rejected promise).

Special Types

timeout :: (Int, a -> b)

A timeout property can be added to types to specify how long receive should wait for an action. It should be an array, the first element is the time in milliseconds for the timeout, the second is optional and is a function that will be called to determine what the returned promise should resolve with (by default, it will reject the promise with Error('TIMEOUT')).

Disclaimer

If you find this enhancer useful, you may not be using redux correctly.

Keywords

FAQs

Package last updated on 08 Apr 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc