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

Improve API #1

Closed
idolize opened this issue Aug 12, 2015 · 5 comments
Closed

Improve API #1

idolize opened this issue Aug 12, 2015 · 5 comments

Comments

@idolize
Copy link
Owner

idolize commented Aug 12, 2015

Right now the library is very un-opinionated, in that the developer can use whatever kind of request library they want (it's not even specific to HTTP) as long as they add the meta.httpRequest field and use unique meta.httpRequest.url parameters.

This is a nice feature, however, there is more boilerplate and required convention than I'd like.

Specifically, requiring the developer to surround the first Action dispatch with an if (!dispatch(myAction)) { return; } in order to bail out of the remaining sequence in the Action Creator is easy to forget.

I'm looking for feedback on how we can improve this API.*

Right now, the best solution I've thought of is to export an additional (optional) helper function that takes the initial ({ done: false }) action as a parameter, as well as a function to run if it succeeds (is not cancelled). This would just be a very simple wrapper over the if (!dispatch(myAction)) { return; } we have now, but I think it would be cleaner for the developer using the library.

Thoughts? @acdlite

@idolize
Copy link
Owner Author

idolize commented Aug 13, 2015

@gaearon I would love to get your thoughts on this if you have a minute 🙇

@johanneslumpe
Copy link

@idolize I think locking people into a specific http/XHR implementation isn't a good thing. Some people use superagent, others axios, somebody else might even use the ajax part of jQuery for their requests. If you think about going with 2) then it might be nice to make the used http library swappable.

@idolize
Copy link
Owner Author

idolize commented Aug 13, 2015

@johanneslumpe Agreed! I doubt I'll go the route of creating my own "redux http library", but if I do rest assured it will be an entirely separate library from this one, and I'll do my best to avoid requiring a specific fetch/XHR library.

@johanneslumpe
Copy link

@idolize Ok good to hear :) But I do agree with the need to get rid of the first !dispatch(...) call - that would soon become a pain haha.

@idolize
Copy link
Owner Author

idolize commented Aug 17, 2015

Helper attemptRequests added in #4

@idolize idolize closed this as completed Aug 17, 2015
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

2 participants