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-trigger-middleware

v0.0.1

Published

Middleware for Redux that calls your function after specified actions

Readme

redux-trigger-middleware

Middleware that lets you call predefined functions on certain actions.

Install it

npm i -S redux-trigger-middleware

Test it

git clone https://github.com/saintcrawler/redux-trigger-middleware.git && cd redux-trigger-middleware

npm i && npm test

Use it

It just sits in your middleware chain and listens for trigger actions. You must supply it with triggers configuration object.

There are 3 types of triggers:

  1. By action type. Triggers if action.type === trigger.type.
  2. By predicate. Triggers if pred(action) returns true.
  3. By array of action types. Triggers if [type1, type2, type3].some(t => t === action.type).

Here is an example config object:

const config = {
  actions: [
    {
      trigger: 'STRING_TRIGGER',
      handler: (action, dispatch) => {
        dispatch({type: 'iHaveBeenTriggered!'});
      }
    },
    {
      trigger: (action) => { return action.payload === 777 },
      handler: (a, d) => d({type: 'lucky!'});
    },
    {
      trigger: ['SOMEBODY', 'CALL', 'ME!'],
      handler: (a, d) => d({type: 'thanks'});
    }
  ]
}

As you may guess handler is a function that will be called on successful trigger.

In order to capture as most actions as possible, you may want to place this middleware at the end of the chain (but, probably, before some loggers, such as redux-logger). That's because your other middlewares can dispatch actions too and, sure, you want to catch 'em all.

Here is the complete example:

import Trigger from 'redux-trigger-middleware'

const trigger = new Trigger(config); // `config` is from above
const enhancer = applyMiddleware(
  //thunk,
  //myOtherMiddleware,
  trigger.middleware,
  //logger
);
const store = createStore(reducer, {}, enhancer);
// And use it as you wish...

Bonus

Also, this is a nice way to perform api calls. Use it together with redux-call-api.

License

ISC