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

redux-easy-actions

v0.4.0

Published

Sugar library for easy creating Flux or Redux actions.

Readme

redux-easy-actions

Redux/Flux action creation made simple

Install

npm install redux-easy-actions

Important

Starting version 0.4 library has been completely rewritten. Decorators using deprecated because of this and library no more support class as container for action creators methods, only plain objects. All became even simpler :)

The Problem

Redux is a great library for JavaScript application building. But there is an inconvenience with the original solution: namely, "ACTION_TYPES" implemented as string constants.

export const ADD_TODO = 'ADD_TODO';
export const DELETE_TODO = 'DELETE_TODO';

Ideally they are stored in a separate file. Thus, an import is required for action creators:

import * as types from '../constants/ActionTypes';

export function addTodo(text) {
  return { type: types.ADD_TODO, text };
}

export function deleteTodo(id) {
  return { type: types.DELETE_TODO, id };
}

...as well as for reducers:

import { ADD_TODO, DELETE_TODO } from '../constants/ActionTypes';

export default function todos(state = {}, action) {
  switch (action.type) {
  case ADD_TODO:
    //some actions
  case DELETE_TODO:
    //some actions
  }
}

...and wait, didn't you forget about the components themselves? Import again!

class TodoForm {
   submit(e){
       this.props.dispatch(this.props.addTodo(e.target.value));
   }
}

Seems like too much links, isn't it? And if you need to change a single action name, about 6 steps are required!

add or rename the string constant -> add or rename action creator -> rename or specify type in the payload -> add or rename the action inside components -> update the reducer's import -> update the reducer's switch statement code -> test it -> be happy

It looks very confusing. With redux-easy-actions this boilerplate will be much easier:

add or rename the action -> update the action inside component -> update switch condition -> test it -> be happy

How it works

First write action creators, and import the EasyActions decorator:


import EasyActions from 'redux-easy-actions';

export default EasyActions({
   ADD_TODO(type, text){
       return {type, text}
   }
   DELETE_TODO(type, id){
       return {type, id}
   }
})

Important: As first argument always passed action type, this happens automatically no need to pass it manually.

That's all! Actions are created. Next connect it to reducer:

import {Constants} from '../actions/actions.js';

export default function todos(state = {}, action) {
  switch (action.type) {
      case Constants.ADD_TODO:
        //some actions
      case Constants.DELETE_TODO:
        //some actions
  }
}

To trigger the action from a component use:

import {Actions} from '../actions/actions.js';

class TodoForm extends React.Component {
   submit(e){
       this.props.dispatch(Actions.ADD_TODO(e.target.value));
   }
}

Great! No strings, easy to change and integrate :)

Is it production-ready?

Please keep in mind that it's still a very early version.

Inspired by

License

MIT