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

rlux-standard-action

v0.0.0

Published

A human-friendly standard for Redux action objects

Downloads

3

Readme

Redux Standard Action

build status npm version

This module is based directly off of flux-standard-action

Introduction

A human-friendly standard for Redux action objects. Feedback welcome.

Motivation

It's much easier to work with Redux actions if we can make certain assumptions about their shape. For example, essentially all Redux actions have an identifier field, such as type, actionType, or actionId. Many Redux implementations also include a way for actions to indicate success or failure, especially as the result of a data-fetching operation. Defining a minimal, common standard for these patterns enables the creation of useful tools and abstractions.

Errors as a first class concept

Redux actions can be thought of as an asychronous sequence of values. It is important for asynchronous sequences to deal with errors. Currently, many Redux implementations don't do this, and instead define separate action types like LOAD_SUCCESS and LOAD_FAILURE. This is less than ideal, because it overloads two separate concerns: disambiguating actions of a certain type from the "global" action sequence, and indicating whether or not an action represents an error. FSA treats errors as a first class concept.

Design goals

  • Human-friendly. FSA actions should be easy to read and write by humans.
  • Useful. FSA actions should enable the creation of useful tools and abstractions.
  • Simple. FSA should be simple, straightforward, and flexible in its design.

Example

A basic Redux Standard Action:

{
  type: 'ADD_TODO',
  payload: {
    text: 'Do something.'  
  }
}

An FSA that represents an error, analogous to a rejected Promise:

{
  type: 'ADD_TODO',
  payload: new Error(),
  error: true
}

Actions

An action MUST

  • be a plain JavaScript object.
  • have a type property.

An action MAY

  • have a error property.
  • have a payload property.
  • have a meta property.

An action MUST NOT include properties other than type, payload, and error, and meta.

type

The type of an action identifies to the consumer the nature of the action that has occurred. type can only be a string constant or a Symbol.

payload

The optional payload property MAY be any type of value. It represents the payload of the action. Any information about the action that is not the type or status of the action should be part of the payload field.

If error is true, the payload MUST be an error object. This is akin to rejecting a promise with an error object.

error

The error property MUST be set to true if the action represents an error.

An action whose error is true is analogous to a rejected Promise. By convention, the payload SHOULD be an error object.

If error has any other value besides true, including undefined and null, the action MUST NOT be interpreted as an error.

meta

The optional meta property MAY be any type of value. It is intended for any extra information that is not part of the payload.

Utility functions

The module redux-standard-action is available on npm. It exports a few utlity functions.

import { isRSA } from 'redux-standard-action';

isFSA(action)

Returns true if action is FSA compliant.