// 建立应用
const app = dva();
// 注册 Model
app.model({ namespace: 'count', state: 0, reducers: { add(state) { return state + 1 }, }, effects: { *addAfter1Second(action, { call, put }) { yield call(delay, 1000); yield put({ type: 'add' }); }, }, }); // 注册视图 app.router(() => <ConnectedApp />); // 启动应用 app.start('#root');
[https://dvajs.com/guide/introduce-class.html#数据流图-1]html
Dva 提供多个 effect 函数内部的处理函数,比较经常使用的是 call 和 put。数据库