// 建立應用
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。數據庫