redux-utilities / redux-promise

FSA-compliant promise middleware for Redux.
MIT License
2.67k stars 134 forks source link

Where is the action's status set to "success" or "error"? #45

Open jcroll opened 7 years ago

jcroll commented 7 years ago

In your documentation it says:

If it receives an Flux Standard Action whose payload is a promise, it will either

  • dispatch a copy of the action with the resolved value of the promise, and set status to success.
  • dispatch a copy of the action with the rejected value of the promise, and set status to error.

I see no other mention of this status field anywhere in the code of this library and I have not seen any field in my resolved action in my testing of this library.

There is a field called error but I am more interested in knowing whether there has been a successful request.

Does it still exist or perhaps this is legacy from and earlier spec of FSA?

I ask b/c I am looking for a way to use FSA to determine if an action is in the process of making a request (e.g. isFetching) how to do this?

mateomurphy commented 7 years ago

The documentation is wrong: the code implements the current FSA spec, success would be the absence of error: true.

jcroll commented 7 years ago

Absence of error can also mean a request has never been initiated.

I wrote additional code to aid with this that basically decorated the FSA spec.

IMO the spec is not verbose enough and should accommodate these additional states.

mateomurphy commented 7 years ago

redux-promise doesn't dispatch when it initiates the request though, so your reducer will not receive an action when it's fetching, only once it's completed or failed. You might want to try a different middleware (like https://github.com/pburtchaell/redux-promise-middleware) for an approach that accommodates knowing when something's fetching.

clownvary commented 7 years ago

@mateomurphy ,u are right, i write a demo and test it, in my case there is no 'status', the right result is :