npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

async-action-creator

v2.2.5

Published

Async actions with steroids creator for Redux or whatever you want

Readme

Async action creator (async-action-creator)

Build Status Coverage Status

Async actions with steroids for Redux or whatever you want.

What

Action creator is a library that helps with handling async actions on redux or similar implementations, giving a couple of methods for dispatching async actions and handling actions status, errors, and responses in a separated reducers so you don't need to hesitate creating a reducer for that.

How

// Creating an action
import {createAction} from 'async-action-creator'
const myAction = createAction('MY_ACTION')

// Mounting the reducer
import {REDUCER_NAME, reducer} from 'async-action-creator'
const rootReducer = combineReducers({
    // All of your reducers
    [REDUCER_NAME]: reducer // Naming is important
})

// Creating the services
export default {
  [myAction.TYPE]: {
    action: myAction,
    uri: "https://api.chucknorris.io/jokes/random",
    method: "GET",
    onResolve: response => response.value,
    onReject: error => error.message,
    options: options => ({
      ...options,
      'content-type': 'text'
    })
  },
};

// Adding the middleware
import {middleware} from 'async-action-creator'

...
createStore(
  rootReducer,
  applyMiddleware(middleware(services))
)
...

// Middleware in action
dispatch(myAction.run())

// Actions automatically dispatched:
{type: 'MY_ACTION'}
{type: 'MY_ACTION_STARTED'}
{type: 'MY_ACTION_RESOLVED', payload: "Jean-Claude Van Damme once attempted to throw a Chuck Norris Roundhouse Kick. He was immediately arrested for fraud."}

// Dispatching async actions manually
const mapDispatchToProps = {
    run: myAction.run, // run({foo: 'bar'}) -> {type: MY_ACTION, payload: {foo: 'bar'}}
    start: myAction.start, // start({foo: 'bar'}) -> {type: MY_ACTION_STARTED, payload: {foo: 'bar'}}
    fetch: myAction.fetch, // fetch({foo: 'bar'}) -> {type: MY_ACTION_FETCH, payload: {foo: 'bar'}}
    update: myAction.update, // update({foo: 'bar'}) -> {type: MY_ACTION_UPDATE, payload: {foo: 'bar'}}
    create: myAction.create, // create({foo: 'bar'}) -> {type: MY_ACTION_CREATE, payload: {foo: 'bar'}}
    remove: myAction.remove, // remove({foo: 'bar'}) -> {type: MY_ACTION_REMOVE, payload: {foo: 'bar'}}
    resolve: myAction.resolve, // resolve({foo: 'bar'}) -> {type: MY_ACTION_RESOLVED, payload: {foo: 'bar'}}
    reject: myAction.reject // reject({foo: 'bar'}) -> {type: MY_ACTION_REJECTED, payload: {foo: 'bar'}}
}

// Getting action status, error and response
// Using this with this `myAction.resolve({foo: 'bar'})` as the last action dispatched
const mapStateToProps = state => ({
    status: myAction.getStatus(state), // => 'resolved'
    error: myAction.getError(state), // => undefined
    response: myAction.getResponse(state) // => {foo: 'bar'}
)}

// Using actions in reducers
switch (type) {
    case myAction.TYPE: // => 'MY_ACTION'
        return {
            ...state,
            hello: 'me'
        }
    case myAction.STARTED: // => 'MY_ACTION_STARTED'
        return {
            ...state,
            hello: 'cat'
        }
    case myAction.FETCH: // => 'MY_ACTION_FETCH'
        return {
            ...state,
            hello: 'rat'
        }
    case myAction.UPDATE: // => 'MY_ACTION_UPDATE'
        return {
            ...state,
            hello: 'rabbit'
        }
    case myAction.CREATE: // => 'MY_ACTION_CREATE'
        return {
            ...state,
            hello: 'owl'
        }
    case myAction.REMOVE: // => 'MY_ACTION_REMOVE'
        return {
            ...state,
            hello: 'elephant'
        }
    case myAction.RESOLVED: // => 'MY_ACTION_RESOLVED'
        return {
            ...state,
            hello: 'dog'
        }
    case myAction.REJECTED: // => 'MY_ACTION_REJECTED'
        return {
            ...state,
            hello: 'dodo'
        }
    default:
      return state
}

Why

Sometimes you need an action status and you had to create a new reducer just for that, also, this reduces the boilerplate of creating a lot of actions for all your async actions.

Installation

yarn add async-action-creator
// or
npm install --save async-action-creator

Tests

// jest tests
yarn test
// jest coverage
yarn cover

Contributors

Simply create a pull request :)

  • Code style: Standard
  • FlowType used

Thanks

This project is based on the idea of make-action-creator by @ajchambeaud, and the getStatus and getError implementations to the same library from @pablen.

License

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.