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

Bailout option Should Throw Error to Reducer #18

Open
dvshnt opened this issue Oct 22, 2015 · 3 comments
Open

Bailout option Should Throw Error to Reducer #18

dvshnt opened this issue Oct 22, 2015 · 3 comments

Comments

@dvshnt
Copy link

dvshnt commented Oct 22, 2015

Use Case:
Using Auth middleware to check if user logged in (via a Token). In the case they are not logged in (there is no Token or it is expired), should be able to throw an error and get out before making the request that you already know will fail.

Maybe this defeats purpose of bailout, but think I am going to fork and implement..

@agraboso
Copy link
Owner

That's actually a very interesting proposal. In fact, I had to use an ugly hack in the testing of a boolean [CALL_API].bailout property — it doesn't return anything, so I have a setTimeout there —, which bothers me. Maybe your idea is a better way of handling [CALL_API].bailout. Its current behavior comes right out of the real-world example in the redux repo, and I have never really thought it over.

I'm very interested in seeing what your implementation will be, so please report back. I'll think about it in the meantime too. The fact that redux-api-middleware is now in the 1.0.0-beta stage is a happy coincidence!

@dvshnt
Copy link
Author

dvshnt commented Oct 28, 2015

Am going to think about this bailout implementation though. One nebulous idea surrounding it is how to differentiate a bailout from other standard errors...

@barrystaes
Copy link
Contributor

First, do you have a PR to demonstrate this? I'm not sure what you mean but that may be because i haven't gotten to the Auth part.

Second, i see you added a schema parameter to getJSON() in your fork and wonder if thats worth including. Do you use it in production this way?

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

No branches or pull requests

3 participants