Closed nmaves closed 8 years ago
Any thoughts on this @svrcekmichal ?
@nmaves hi finally I have time to review, I've been quite busy lately.
{ payload, meta: { ...responseMeta }, action: newAction }
or error value respectively? I believe returning just new action object is enough, because every one can create config to set what he need thereclient.request(...).then(...)
is Promise, so why not use this one and create new? You can do return Promise.reject(newAction)
in error handler or just return newAction
in success handler and you will have the same functionality{ payload, meta: { ...responseMeta }, action: newAction }
you are sending payload in .payload
and .action.payload
and you are sending all meta in .meta
and .action.response
. So it's all duplicate. Please, just return newAction
object, this way everyone who will change onSuccess
or onError
handler in config will stay consistent with whatever he wante => process.env.NODE_ENV !== 'production' ? console.log(e) : Raven.captureException(e) // for xample if project use sentry
const promise = somePromise().then(function(response){
//do whatever you want;
return response;
}, function(error) {
//do whatever you want;
return Promise.reject(error);
})
If you do it this way, you can use promise.then(...)
anywhere you want, you don't need to do:
return new Promise((resolve,reject)=>{
const promise = somePromise().then(function(response){
//do whatever you want;
resolve(response);
}, function(error) {
//do whatever you want;
reject(error);
})
})
I have updated per your suggestions. The only thing I was unsure about was the rejection with the fatal axios error. I don't like that we have two different objects being rejected.
I have created issue #10 . Please, if you have time make a little review, if you will be okay, I will create PR with that. I believe this solves the last issue. According to default action change, I would again suggest to return newAction from middleware, because it has information about current response and action which trigger this new action
Michal, I have updated the middleware.js to reflect your suggestions. I will be away on holiday for the next week but I will check back in when I can.
@nmaves Enjoy your holiday. I have published package with version 1.0.0-rc.0
in case there's some bug ... you can check it out 👍
This should take care of issue #7.