New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

awral

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awral

Awesome Wrapper for Redux Action's Lifecycle

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

AWRAL

Greenkeeper badge

Awesome Wrapper for Redux Action's Lifecycle

Swiss Army knife for async actions in Redux.

Why?

Assume you're using redux and redux-thunk.

README IN PROGRESS.

PLEASE, CHECK SOURCES!

When you work with async stuff you probably have next code in your container:

const mapDispatchToProps = dispatch => ({
	getUser (id) {
		dispatch(GET_USER(id))
	}
})

Where GET_USERS is a next async action:

export const GET_USER = id => async dispatch => {
	dispatch({type: 'GET_USER_PENDING'})
	const payload = await getUserFromServer(id)
	if (resultOK(payload)) {
		dispatch({type: 'GET_USER_SUCCESS', payload})
	} else {
		dispatch({type: 'GET_USER_FAIL', payload, error:true})
	}
	dispatch({type: 'GET_USER_FINALLY', payload})
}

With AWRAL you can just write:

const GET_USER = awral(getUserFromServer)('GET_USER')

How?

There is only one method: Awral.of(). of() allows you to extend/rewrite your "awrals":

import Awral from 'awral'
const checkResponseFromAPI = (result) => result.ok
const transformResultAfter = (result) => result.data
// const success = ({dispatch, payload}) => {}

const awralCheck = Awral.of({check: checkResponseFromAPI})
const awralCheckTransformBefore = awralCheck.of({})
const awral = Awral.of(check: checkResponseFromAPI)

Keywords

react

FAQs

Package last updated on 29 Oct 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