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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-easy-redux

v1.0.8

Published

一个将redux redux-saga做了简易封装的轮子

Downloads

13

Readme

react-easy-redux

English | 中文版

A plugin that simply encapsulates redux and redux-saga. It can be used directly for React 、React-Native

Notice

This package depend on redux、redux-saga 、react-redux,So you no need install them additionally !!!!

Feature

  1. Easier integration of redux, redux-saga. if you install this package,You don't need to install redux、redux-saga、react-redux additionally.

  2. Automatically define a loading variable in the redux state when you trigger a effect function. Support for custom Plugin.

Background

redux + redux-saga directly is not friendly to novices. Especially redux-saga, many novices are confused about it.

It inspired by dva.js, Why not use dva.js directly ?

Because it is too large, contains many features that are not needed for small and medium projects, and cannot be used directly in React-Native.

Getting Started

Installation

npm i react-easy-redux --save

Basic Usage

import { Provider, getStore,connect } from 'react-easy-redux';

const model = {
    namespace:'test',
    state:{
        msg:'hello,world'
    },
    effects:{
        *fetch(payload,{call,put}) {
            const response = yield call(fetchApi,payload);
            yield put({
                type: 'save',
                payload: {
                    msg:response
                }
            })
        }
    },
    reducers:{
         save(state, action) {
            return {
                ...state,
                ...action.payload
            };
        },
    }
};

// init store
const store = getStore([model]);



export default class App extends React.Component {
    render: function() {
        return (
           <Provider store={store}>
              <div>hello,world</div>
           </Provider>
        )
    }
}

// connect Component
const Test = (props) => {
    return (
        <div>{props.msg}</div>
    )
}

const mapStateToProps = ({test}) => ({
    msg: test.msg
})

export const ConnectTest = connect(Test,mapStateToProps);

API

Model

| propName | type | required | desc | | :-------: | :----: | :------: | :----------------------------------------------------------------------------------------: | | namespace | string | true | The name of the module that was eventually injected into the reducer | | state | object | true | State injected into the corresponding reducer module | | effects | object | false | Effects injected into redux-saga, you can use effects methods like call、 put and so on... | | reducers | object | false | Reducer calculation method in redux |

connect

The method for injecting react components into redux is simplified on the basis of react-redux, and it automatically injects dispatch methods into components.

const Test = props => {
    return <div>{props.msg}</div>;
};

const mapStateToProps = ({ test }) => ({
    msg: test.msg
});

export const ConnectTest = connect(Test, mapStateToProps);

dispatch

The component after connect will have methods to trigger the corresponding effects methods. Returns a Promise. The triggered effects method will trigger the corresponding loading = true before use, and loading = false after execution.

this.props.dispatch({
    type: 'namespace/effectFunctionName',
    payload: {
        a: 1,
        b: 1,
        catchSelf: false
    }
});

Parameters of the dispatch method

| name | type | required | desc | | :-------: | :-----: | :------- | :-----------------------------------------------------------------------------------------------------------------------------------------------------: | | catchSelf | boolean | false | Defaults false,If set to true, the exception of the triggered effect method will be thrown, and the promise returned by dispatch needs to catch itself |

loading

Comes with a loading plugin. Each time the effect method is triggered, a loading variable is automatically generated in the state of redux for loading in exec asynchronous method.

const Test = props => {
    useEffect(() => {
        props.dispatch({
            type: 'test/aFun'
        });
    });
    return <div>{props.testLoading}</div>;
};

const mapStateToProps = ({ test,loading }) => ({
    msg: test.msg,
    testLoading:loading['test/aFun']
});

export const ConnectTest = connect(Test, mapStateToProps);

Next

No

Other

Welcome PR!!!! The first release of the npm package must have many shortcomings.

License

MIT

Create By daizq