Score
0
Watch 1 Star 5 Fork 0

fwh1990 / redux-modelTypeScriptMIT

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
typescript项目最好用的redux框架 spread retract

https://github.com/fwh1990/redux-model

Clone or download
Loading...
README.md

Redux模型是对原生redux的一次面向对象封装,OOP方案可以实现隐藏重复代码、提高工作效率以及减少开发时间的效果。你只需要花半个小时,就能完全了解模型的用法,并从中受益。

Travis (.com) Coveralls github

特性

  • 纯面向对象
  • 支持mvvm操作
  • 代码量比函数式redux写法少一半
  • action与reducer合体
  • 无需定义types
  • 无需包裹dispatch()
  • 完美支持typescript,拥有100%无死角的代码类型提示
  • 请求操作内置loading状态

class TestModel extends Model {
    increase = this.action((state) => {
        state.counter += 1;
    });

    getProfile = $api.action((userId) => {
        return this
            .get('/api/profile/' + userId)
            .onSuccess((state, action) => {
                state.users[userId] = action.response;
            });
    });

    protected initReducer() {
        return {
            counter: 0,
            users: {},
        };
    }
}

文档

点击查看在线文档


欢迎您自由使用并随时创建issue和PR。

Comments ( 0 )

Sign in for post a comment

TypeScript
1
https://gitee.com/fwh1990/redux-model.git
git@gitee.com:fwh1990/redux-model.git
fwh1990
redux-model
redux-model
master

Help Search

191139_cd20d5fd_5186603 191143_ebef6f8d_5186603