原因:function2的value2需要function1的response.value1,即function1的请求返要回作为function2请求参数。因为是异步的,所以要把function2的触发放入function1的回调中。
// model中的subscriptions或者effect
dispatch({
type: 'function1',
callback: (_response) => {
if(_response.success){
dispatch({ type: 'function2', payload: {value2: _response.value1 } })
})
// model中的effect
function1({ callback },{ call }) {
const _response = yield call(callService, reqParam);
if(callback && typeof callback == "function") {
callback(_response);
}
}
// model中的effect
function2({ payload },{ call }) {
_payload.value2 = payload.value2
yield call(callService, _payload);
}