- 介绍
- 核心概念
- 插件列表
- API 列表
- tangdao(opts)
- dispatch
- actionType
- actionCreator
- useModel
- nextTick
- getApp
- 迁移指南
通过 .
的方式获取具体 model 下的 actionCreator,具体如下:
model
const count = {
namespace: 'count',
state: 0,
reducers: {
add(state, { payload }) {
return state + payload;
}
},
effects: {
* asyncAdd({ payload }, { put }, actionCreator) {
yield new Promise(resolve => setTimeout(resolve, 1000));
yield put(actionCreator.add(payload));
}
}
}
组件
import React from 'react';
import { connect, actionCreator } from '@maoyan/tangdao';
console.log(actionCreator);
/* 输出
{
add: function(payload) {
return {
type: 'count/add',
payload
}
},
asyncAdd: function(payload){
return {
type: 'count/effect/asyncAdd',
payload
}
}
}
/*