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

ez-saga

v18.1.0

Published

The ez-saga project is a project that imitates dva-js

Readme

The ez-saga project is a project that imitates dva-js

Why ez-saga?

ez-saga is designed to simplify Redux + Saga development, offering a modern, developer-friendly experience similar to dva but with significant improvements:

| Feature | ez-saga | dva | Raw Redux-Saga | | :--- | :--- | :--- | :--- | | Model Architecture | Centralized (State + Reducers + Effects) | Centralized | Scattered (Actions, Switch, Watchers separated) | | TypeScript Support | First-class, with automatic type inference helper | Poor / Manual | Good but verbose | | Hot Module Replacement | Zero-config (Vite & Webpack 5), supports hot-swapping reducers & effects | Broken / Unmaintained | Manual / Complex setup | | API Simplicity | High (createApp, regist) | High | Low (High boilerplate) | | Build Tooling | Vite & Webpack 5 Support | Webpack 3/4 (Roadhog/Umi dependency) | Agnostic | | Maintenance | Active | Inactive / Legacy | Active |

Key Advantages:

  • Zero Boilerplate: No more action types, switch statements, or yield take watchers. Just write functions.
  • Modern HMR: Built-in plugins for Vite and Webpack to keep your state and logic hot-updatable without page reloads.
  • Decoupled: Works with any React setup, not tied to a specific framework like Umi.

how to use?

install

npm install ez-saga --save

This is the entry file of the project.

import 'core-js';
import 'react';
import React from 'react';
import ReactDom from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import ezSaga from 'ez-saga';
import Views from './views';
let app = ezSaga.createApp();
window.app = app;
class RouterConfig extends React.Component {
  render() {
    return (
      <Provider store={app.store}>
        <BrowserRouter>
          <Views app={app} />
        </BrowserRouter >
      </Provider>
    );
  }
}
ReactDom.render(<RouterConfig />, document.getElementById('root'));

Now let's define a model 'userModel.js'

export const modelName = 'user';

const model = {
  /** model name */
  name: modelName,
  /** default state*/
  state: {
    userDetial: null
  },
  reducers: {
    /** save user reducer */
    saveUser: (state, action) => {
      let newStat = {
        ...state
      };
      newStat.userDetial = action.payload.userDetial;
      return newStat;
    }
  },
  effects: {
    /** getUserDetial effect */
    * getUserDetial({ payload }, { call, put, select }) {
      //let user = payload;
      let user = {
        id: '1',
        name: 'tom'
      };
      //async method call
      //yield call('async', agr1, agr2, arg3, ....);

      //save user
      yield put({
        type: `${modelName}/saveUser`,
        payload: {
          user: user
        }
      });
    },
    /** deleteUserDetial effect */
    *deleteUserDetial({ payload }, { call, put, select }) {
      let id = payload;
      //The saveState effect is built-in by default.
      yield put({
        type: `${modelName}/saveState`,
        payload: {
          userDetial: null
        }
      });
    }
  }
};

export default model;

Now we can register this model.

import userModel from './userModel';
window.app.regist(userModel);

Next, we define a page.

import React from 'react';
import { modelName } from './userModel';
import { connect } from 'react-redux';

class View extends React.Component {

  constructor(props) {
    super(props);
    this.handleDelete = this.handleDelete.bind(this);
  }

  handleDelete() {
    this.props.dispatch({
      type: `${modelName}/deleteUserDetial`, payload: {}
    });
  }

  componentDidMount() {
    this.props.dispatch({ type: `${modelName}/getUserDetial`, payload: { id: 1 } });
  }

  render() {
    return (
      <div>
        <div>userDetail:{JSON.stringify(this.props.userDetail)}</div>
        <button onClick={this.handleDelete}>
          delete
        </button>
      </div>
    );
  }
}

function stateMapProps(state, props) {
  let model = state[modelName];
  return {
    userDetail: model.userDetail
  };
}

export default connect(stateMapProps)(View);

We can invoke reducers and effects using dispatch, and we can obtain the results returned by effects.

Vite Plugin for HMR

ez-saga provides a built-in Vite plugin to support Hot Module Replacement (HMR) for models. This allows you to modify effects and reducers during development without reloading the page.

Usage

  1. Import the plugin in your vite.config.ts:
import { defineConfig } from 'vite';
import ezSagaHmr from 'ez-saga/vite';

export default defineConfig({
  plugins: [
    ezSagaHmr(), // Add ez-saga HMR plugin
    // other plugins...
  ]
});
  1. That's it!

The plugin automatically detects your model files and injects hot update logic. When you modify a model file, ez-saga will:

  • Cancel old saga tasks.
  • Re-register the model reducers (hot-swap logic).
  • Restart the effects.

Note: This requires your model files to be exported using export default and contain a name property.

Webpack Plugin for HMR

For Webpack 5 users, ez-saga also provides a compatible HMR plugin.

Usage

  1. Import the plugin in your webpack.config.js:
const EzSagaWebpackPlugin = require('ez-saga/webpack').default; // Notice the .default for CJS

module.exports = {
  // ...
  plugins: [
    new EzSagaWebpackPlugin(),
    // other plugins...
  ]
};

This plugin automatically configures the HMR loader for your model files.