set error to true when payload instanceof Error#136
set error to true when payload instanceof Error#136globalchubby merged 3 commits intoredux-utilities:masterfrom
Conversation
Should set error to true when payloadCreator return error
globalchubby
left a comment
There was a problem hiding this comment.
@xiaohanzhang Thanks for the contribution!
- can you write some tests around this?
- can you describe some specific use cases (when I have an error, I usually pass the error to the action creator directly)?
|
#43 is related. @xiaohanzhang can you describe the use case? @timche if the use case makes sense, I don't see a problem with merging this, as it seems to have been asked for and supported before. |
|
@yangmillstheory Thanks for great work and quick reply, I added a test for it I feel it will make more sense to put arguments validator inside actions, otherwise we need check it in every components. |
|
Thanks @xiaohanzhang. I think we should merge (pending @timche's feedback), but I would like to understand this a bit deeper, beyond avoiding writing wrappers. Can you give a couple of examples of an actual flow in your application where this comes in useful? What kind of validation are you doing in your payload creators? |
|
We have some rest api action, I want add more client-side validation before it send to server. |
|
@timche please let us know if there are any blockers. |
|
Hi, this new change doesn't seem to affect payloadCreator that returns a Promise, there's no error field in the dispatched action. I'm using redux-promise as well.
myAsyncFunc does some network requests and returns a Promise that can resolve into an Error. Can you suggest a solution? Is it fine to resolve the payload before checking if it's an Error? |
|
@holybom I usually just throw an error inside myAsyncFunc, redux-promise will catch that error: |
Should set error to true when payloadCreator return error