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-hurakken

v1.3.1

Published

Throttling as a Redux Middleware (4M compliant)

Downloads

3

Readme

hurakken

Advanced throttling module as a Redux Middleware, by Victor Buzzegoli

Lightweight, Powerfull, 4M 1.6 compliant (check out : Modern Modular Middleware Model)

Often used along with Axiom

Installation

To install Hurakken in your project, navigate to your project folder in your terminal and run :

npm i --save redux-hurakken

Setup

To start using Hurakken, you will first need to apply the middleware to your store, just like any redux middleware :

    ...
    import hurakken from "redux-hurakken";
    ...
    export default createStore(rootReducer,applyMiddleware([hurakken]));

Note that a light version of Hurakken is already included in Axiom.

Usage

Using ES6+ syntax

    import * as actions from "../constants/action-types";

    export const clearArray = () => {
        type: actions.CLEAR_ARRAY,
        payload: [],
        hurakken: {
            throttle: 5000
        }
    }

throttle is a value in milliseconds for which this action will not be dispatchable again. Note that due to Javascript single threaded environment, this value can be subject to slight variant, and is therefore not precisely defined.

  • Throttling can be espacially useful to prevent from overloading a network by rejecting spam attempts. For that reason, Hurakken is included natively into our REST Middleware Axiom.

Behaviour

  • Use onAccepted and onRejected to override the default behaviour

Note that these functions are called reactions, accordingly to the Modern Modular Middleware Model. Therefore they contain a next argument that can be use to release an action to the reducer (or next middleware). They can be used like :

In /reactions :

export const customReaction = (action, next, dispatch) => {
    console.log("Rejected Action :", action);
    next(action);
};

In /actions :

    import * as actions from "../constants/action-types";
    import { customReaction } from "../reactions/customReaction";

    export const clearArray = () => {
        type: actions.CLEAR_ARRAY,
        payload: [],
        hurakken: {
            throttle: 5000,
            onRejected: customReaction
        }
    }

If you were to use a non 4M compliant middleware such as redux-thunk, which is deprecated by the 4M documentation, please note that, by default, using/dispatching the action returned by onAccepted or onRejected will not trigger Hurakken again even though the arguments are still contained in the action's parameters. To force triggering Hurakken again, use : _skip: false or remove _skip in the hurakken node.

  • Use log: true to print the middleware logs in the console (add xlog: true for extended logs)

Here is a overview of every options possible:

    hurakken: {
        throttle: 3000,
        log: true,
        xlog: true,
        onSuccess: (action, next, dispatch) => {
            //...
        },
        onRejected: (action, next, dispatch) => {
            //...
        }
    }

Version

1.3.1

License

The MIT License

Copyright 2018 - Victor Buzzegoli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

Contact

@victorbuzzegoli on Twitter