# redumd

> redux framework

Latest version **3.0.7** (published 2020-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install redumd
pnpm add redumd
yarn add redumd
bun add redumd
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.7 |
| Published | 2020-06-28 |
| First published | 2018-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6 |
| Dependencies | 4 |
| Unpacked size | 72.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | zhbhun |
| Maintainers | zhbhun |

## Links

- npm: https://www.npmjs.com/package/redumd
- Repository: https://github.com/zhbhun/redumd
- Issues: https://github.com/zhbhun/redumd/issues
- npm.io page: https://npm.io/package/redumd

## Dependencies (4)

- [normalizr](https://npm.io/package/normalizr.md) ^3.0.0
- [redux-saga](https://npm.io/package/redux-saga.md) ^0.16.0
- [lodash.mergewith](https://npm.io/package/lodash.mergewith.md) ^4.0.0
- [redux-devtools-extension](https://npm.io/package/redux-devtools-extension.md) ^2.0.0

## Recent versions

- 3.0.7 (latest) — 2020-06-28
- 3.0.6 — 2020-06-18
- 3.0.5 — 2020-06-17
- 3.0.4 — 2020-06-17
- 3.0.3 — 2020-06-16
- 3.0.2 — 2020-06-15
- 3.0.1 — 2020-06-15
- 3.0.0 — 2020-06-12
- 2.0.3 — 2020-05-22
- 2.0.2 — 2020-05-21
- 2.0.1 — 2020-05-11
- 2.0.0 — 2020-05-11
- 1.7.2 — 2019-06-13
- 1.7.1 — 2019-06-11
- 1.7.0 — 2019-02-01
- … 9 more at https://npm.io/package/redumd/versions

## README

# Redumd

Redumd 是基于 redux 封装的易于使用的状态管理框架。

- 将 redux 的 action，reduce 和 selector 等以 Model 的形式放在一个模块内实现（类似与 Dva.js 的 model）；
- 集成 redux-saga，轻松实现 redux 的异步逻辑；
- 内置易于使用的业务状态和应用状态管理 Model。

## 用法

```javascript
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { init, Model } from 'redumd';

class Counter extends Model {
  static defaultState = {
    timers: 0
  };

  static reducers = {
    increment: function(state) {
      return { timers: state.timers + 1 };
    },
    decrement: function(state) {
      return { timers: state.timers - 1 };
    }
  };

  constructor(namespace) {
    super(namespace);

    this.getTimers = state => this.getState(state).timers;
  }
}

class Demo extends Component {
  incrementIfOdd = () => {
    if (this.props.value % 2 !== 0) {
      this.props.onIncrement();
    }
  };

  incrementAsync = () => {
    setTimeout(this.props.onIncrement, 1000);
  };

  render() {
    const { value, onIncrement, onDecrement } = this.props;
    return (
      <p>
        Clicked: {value} times <button onClick={onIncrement}>+</button>{' '}
        <button onClick={onDecrement}>-</button>{' '}
        <button onClick={this.incrementIfOdd}>Increment if odd</button>{' '}
        <button onClick={this.incrementAsync}>Increment async</button>
      </p>
    );
  }
}

const counter1 = new Counter('counter1');
const counter2 = new Counter('counter2');
const store = init({
  models: [counter1, counter2]
});
const rootEl = document.getElementById('root');

const render = () =>
  ReactDOM.render(
    <div>
      <div>
        <h1>Counter1</h1>
        <Demo
          value={counter1.getTimers(store.getState())}
          onIncrement={() => store.dispatch(counter1.actions.increment())}
          onDecrement={() => store.dispatch(counter1.actions.decrement())}
        />
      </div>
      <div>
        <h1>Counter2</h1>
        <Demo
          value={counter2.getTimers(store.getState())}
          onIncrement={() => store.dispatch(counter2.actions.increment())}
          onDecrement={() => store.dispatch(counter2.actions.decrement())}
        />
      </div>
    </div>,
    rootEl
  );

render();
store.subscribe(render);
```

## 文档

- [API](./doc/api/README.md)

## 示例

- [Counter](https://codesandbox.io/s/xr60620z0o)

## License

MIT

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