[英]What is the correct way to implement transactions with redux
我需要對服務器運行兩個查詢,如果成功執行某些操作。 沒有redux
我會像使用Q
庫那樣做:
$q.all([service.doAction1(),service.doAction2()]).then(function(){
//perform some actions
})
我的問題是如何使用redux做同樣的事情? 我最好的猜測是我必須實現使用上面列出的相同方法的中間件:
function(next) {
return function(action) {
$q.all([service[action.requests[0]](),service[action.requests[1]]()]).then(function(result){
next(result);
})
}
}
我想要么:
終極版,形實轉換; 請參閱此處的異步示例: https : //github.com/gaearon/redux-thunk#motivation
要么
redux-saga https://github.com/yelouafi/redux-saga
有助於解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.