# ee-redux

> easyredux

Latest version **1.1.11** (published 2019-10-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install ee-redux
pnpm add ee-redux
yarn add ee-redux
bun add ee-redux
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.11 |
| Published | 2019-10-21 |
| First published | 2019-10-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lee |
| Maintainers | leekk |
| Keywords | redux, easy redux |

## Links

- npm: https://www.npmjs.com/package/ee-redux
- npm.io page: https://npm.io/package/ee-redux

## Dependencies (1)

- [redux](https://npm.io/package/redux.md) ^4.0.4

## Recent versions

- 1.1.11 (latest) — 2019-10-21
- 1.1.10 — 2019-10-21
- 1.1.9 — 2019-10-21
- 1.1.8 — 2019-10-21
- 1.1.7 — 2019-10-21
- 1.1.6 — 2019-10-21
- 1.1.5 — 2019-10-21
- 1.1.4 — 2019-10-21
- 1.1.3 — 2019-10-21
- 1.1.2 — 2019-10-21
- 1.1.1 — 2019-10-21
- 1.1.0 — 2019-10-21
- 1.0.0 — 2019-10-18

## README

## why

在使用redux的过程中遇到诸如:
* 模块化数据更新操作产生的，reducer书写繁琐，产生没必要的运行开销。
* 异步数据流管理
* 动态的模块数据诸如与销毁(todo)
的问题

## how


```typescript
  import easyRedux from "easyRedux";
  // base struct
  const module = {
      // 模块state
      state: {
          a: 1,
          b: "a",
          c: "c"
      },

      reducer: {
          // 同步更新当前模块state
          MCReducer: (state, payload) => {
              return payload
          }
      },
      // 异步操作
      effects: {
          mockA: async (payload, state, dispatch, store) => {
              return Promise.resolve(payload).then((payload)=>{
                  console.log("payload", payload);
                  // 直接设置根模块的state变量a
                  dispatch.a(payload)
              });
          },
          mockB: async (payload, state, dispatch, store) => {
              // 根据路径修改子模块，b变量。
              return Promise.resolve(8).then(dispatch.ModuleA.b);
          },
          mockB: async function(payload, state, dispatch, store) {
              // this用于更新当前模块的b变量
              return Promise.resolve(payload).then(this.b)
          }
      },
      modules: {
          ModuleA,
          ModuleB
      }
  }
  const { store, inject, destory} = easyRedux(module)
  store.dispatch({
    type: "module/subModule/[stateName|reducer|effects]",
    payload
  })
  store.dispatch.module.(...subModule).[stateName|reducer|effects]
  // 模块注入
  inject(modulepath, module)
  // 模块销毁
  destory(modulepath)

  // 当在业务场景需要了解异步的effect是否执行完毕我们可以
  await store.dispatch.(...submodule).effectName();
  // ... donext
```

---
_Source: https://npm.io/package/ee-redux · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
