/dva-model-creator

write type strong dva model

Primary LanguageTypeScript

Dva Model Creator

Build Status Codecov NPM version

Inspired by aikoven/typescript-fsa and dphilipson/typescript-fsa-reducers

Write type strong dva model

配合 Umi Pro 食用更佳 umijs/vscode-extension-umi-pro

how to use

yarn add dva-model-creator
import { DvaModelBuilder, actionCreatorFactory } from 'dva-model-creator';

const actionCreator = actionCreatorFactory('namespace');
const add = actionCreator<number>('add');
const minus = actionCreator<number>('minus');
const asyncAdd = actionCreator<number>('asyncAdd');
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));

interface Counter {
  number: number;
}

const model = new DvaModelBuilder<Counter>({ number: 0 })
  .case(add, (state, payload) => {
    return {
      number: state.number + payload,
    };
  })
  .case(minus, (state, payload) => {
    return {
      number: state.number - payload,
    };
  })
  .takeEvery(asyncAdd, function*(payload, { call, put }) {
    yield call(delay, 100);
    yield put(add(payload));
  })
  .build();

export default model;

招聘

食亨团队始于 2017 年,总部位于上海,目前员工近 800 人。服务超过 300 个国内知名餐饮连锁品牌,近万家门店,覆盖 85 个城市。是国内领先的规模化、系统化运营的餐饮外卖运营公司。得到**顶尖资本助力,获得了来自红杉资本**及高榕资本领投的过亿元融资。

招聘前端小伙伴。

邮箱 fandi.yuan@shihengtech.com