你可以有它執行除了其操作它調用另一個動作一個動作,來實現這一點,你需要有一個redux-async-transitions,示例代碼如下
function action1() {
return {
type: types.SOMEFUNCTION,
payload: {
data: somedata
},
meta: {
transition:() => ({
func:() => {
return action2;
},
path : '/somePath',
query: {
someKey: 'someQuery'
},
state: {
stateObject: stateData
}
})
}
}
}
給出這裏是異步調用
function asynccall() {
return {
types: [types.PENDINGFUNCTION, types.SUCCESSFUNCTION, types.FAILUREFUNCTION],
payload: {
response: someapi.asyncall() // only return promise
}
meta: {
transition: (state, action) => ({
onPending:() => {
},
onSuccess: (successdata) => {
//gets response data can trigger result based on data
},
onFail: (promiseError) => {
//gets error information used to display messages
}
})
}
}
}
謝謝! requestFactory是我目前正在使用的一種方法,但在重放失敗的請求時,我很難保持它無狀態。 – JonnyReeves