I need to run two queries to a server and if successful perform some action. Without redux
I'd do it like that using Q
library:
$q.all([service.doAction1(),service.doAction2()]).then(function(){
//perform some actions
})
My question is how the same should be done using redux? My best guess is that I have to implement middleware which will use the same approach listed above:
function(next) {
return function(action) {
$q.all([service[action.requests[0]](),service[action.requests[1]]()]).then(function(result){
next(result);
})
}
}
I think either:
redux-thunk; See the async example here: https://github.com/gaearon/redux-thunk#motivation
or
redux-saga https://github.com/yelouafi/redux-saga
Would help solve your issue.