2
我有兩個按以下方式調用的redux操作。Redux操作未被第二次調用
export function action1(params) {
//This line is always called.
return (dispatch) => {
//This line is not called the second time.
return MyApi.call1(params)
.then(response => {
// some logic
return dispatch(someFunction1());
})
.catch(error => {
throw(error);
});
};
}
export function action2(params) {
return (dispatch) => {
return MyApi.call2(params)
.then(response => {
// call the first API again
action1();
return dispatch(someFunction2());
})
.catch(error => {
throw(error);
});
};
}
當第一次加載視圖,action1
被視圖的構造方法中調用。在執行操作並在相同視圖中觸發action2
時,需要在action2
的成功上調用action1
以從服務器獲取更新列表。不幸的是,當第二次調用action1
時代碼沒有任何錯誤。
我在這裏錯過了什麼?
btw,你還沒有調度action1,如:'dispatch(action1(params))'; –
它的工作。這對我來說太蠢了。你可以發佈這個答案,以便我可以接受嗎? –