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

redux-async-await

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-async-await

redux middleware to es7 async/await syntax action and promise action

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
247
increased by4.22%
Maintainers
1
Weekly downloads
 
Created
Source

redux-async-await

Build Status

redux middleware deal with es7 async/await syntax action and promise action

install

npm i -S redux-async-await

usage

// apply middleware
import {createStore, applyMiddleware} from 'redux';
import asyncAwait from 'redux-async-await';
const store = applyMiddleware(asyncAwait)(createStore)(yourRootReducer);

------------
// **actions.js**
// use async/await
export async function getInfo(id){
  const data = await fetch('/getUserInfo/' + id).then(res => res.json())
  return {
    type: 'GET_USERINFO',
    data
  }
}
export function getList(){
  return fetch('/getList').then(res => res.json()).then(data => ({
    type: 'GET_LIST',
    data
  }))
}

----------------
// dispatch
try{
  const data = await store.dispatch(getInfo(20)) // if resolve, data === action.data
} catch(e) {
  console.log(e) // if reject
}

Keywords

FAQs

Package last updated on 25 Oct 2016

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