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

simplify-action-middleware

v1.2.3

Published

提高redux 的dispatch的能力,精简action部分。为了兼容目前框架,采用jquery进行web请求后期可改为whatwg-fetch

Downloads

6

Readme

simplify-action-middleware

简化对redux异步action的处理中间件,兼容其他异步处理中间件,thunk等...


travis dep npm downloads

install:

npm install simplify-action-middleware

Tips

如果对于options配置项有更多需求的可以提issues,大家一起丰富。


Usage simplify-action-middleware

import simplify  from 'simplify-action-middleware';

redux中间件的目的是在action阶段做一些处理,用来增强dispatch的能力 所以我们在创建sotre的时候注入中间件,并且与其他中间件兼容,开发这个中间件的目的是为了简化 action过程的一些操作,同时处理了异步action,在对现有项目改造阶段同时引入 thunk和simplify, 是为了兼容两种不同对于异步action的处理方式,并不会引起冲突; options 是一个配置对象,用来传入一些外部的函数处理一些异常 exp:session超时的处理、 或者一些模态框函数、

var store = createStore(
    combineReducers(reducers),
    compose(applyMiddleware(thunk,silplify(options)))
);

这是一个注入到页面的action,使用simplify后就这么精简就可以了,区别之前繁琐的aciton构造, 提高开发效率,让开发者专注于业务组件和数据流的设计而不用关心框架其他方面。 当然这个返回的对象也是可以配置的,

export const searchTreatCases = (postData) =>{
  return {
      url:'../patient/patientCaseSearch',
      data:{"params":JSON.stringify(postData)},
      types:['SEARCHTREAT_START','SEARCHTREAT_SUCCESS',null]
    }
}

配置对象:
configObj :
    url , 
    types , //为三种不同类型action状态,分别为开始请求、请求成功、请求失败,没有的类型请用''或null代替
    method , //post
    data , 
    async, //默认true
    timeout,//默认最大值 Number.MAX_VALUE
    contentType // 默认 "application/x-www-form-urlencoded;charset=utf-8;"

只需要传入一些请求必须的参数; 目前我们仍引用了juqery库作为web请求的库(import $ form ‘jquery’), 后期随着项目的改进可改为fetch等库。

future

对于瞬间请求过多的情况下、以后考虑加入requestMQ特性

develop

    1、npm install
    2、npx babel src --out-dir lib
    3、npm publish