Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jcroll opened this issue Oct 21, 2016 · 4 comments
Open

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

jcroll opened this issue Oct 21, 2016 · 4 comments

Comments

@jcroll
Copy link

jcroll commented Oct 21, 2016

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?

@jcroll jcroll changed the title Where is the action's status set to "success Where is the action's status set to "success" or "error"? Oct 21, 2016
@mateomurphy
Copy link

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

@jcroll
Copy link
Author

jcroll commented Nov 11, 2016

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
Copy link

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
Copy link

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

  • resolve
action:{
type:xxx,
payload:{xxx}
}
  • reject
action:{
type:xxx,
payload:{xxx},
error:true
}

so we just can only use error as a condition to judge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants