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 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-actions-class

v1.0.4

Published

Create action creators and types with minimal redundancy.

Downloads

6

Readme

redux-actions-class

Build Status

Create action creators and types with minimal redundancy.

Install

npm i redux-actions-class --save

Why not redux-actions or redux-act?

The benefits of this package compared to redux-actions is that you don't have to manage a separate actionTypes file; you get to define actions on an orderly object literal and all your types and creators will live on just one object. Just a matter of preference.

Considering redux-act, we achieve a similar goal of not having to declare or manage string constants, however, this package still enforces the SCREAMING_UNDERSCORE_CASING we are so used to.

In any case, both of those package offer some goodies beyond actions, like higher level reducer creators. For that I recommend coupling this package with redux-create-reducer - from the example in the redux reducing boilerplate section. As far as FSA enforcement goes, I got nothing but am open to PRs and suggestions.

Example

import Actions from 'redux-actions-class'
import { assert } from 'chai'

const actions = new Actions({
  
  // use falsy value for actions with no payloads
  DISPLAY_COLORS: null,
  
  // use string for single argument (like payload, if you use FSAs)
  ADD_COLOR: 'color',
  
  // use array for multiple arguments
  MIX_COLORS: ['color1', 'color2']
  
  // thunks work, too
  ADD_COLORS (...colors) {
    return dispatch => colors.forEach(color => dispatch(this.addColor(color)))
  }
})

// all keys from above spec will be added directly to your actions object
actions.DISPLAY_COLORS
// => 'DISPLAY_COLORS'

// all creators in camelCase form that can be dispatched are added too
typeof actions.displayColors
// => 'function'

// all types are also grouped together on the `types` field
// (the values are identical)
actions.types.DISPLAY_COLORS
// => 'DISPLAY_COLORS'

// likewise, all action creators are available through the creators key
import { bindActionCreators } from 'redux'

const mapDispatchToProps = dispatch => {
  bindActionCreators(actions.creators, dispatch)
}

License

MIT