-
Notifications
You must be signed in to change notification settings - Fork 6
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
Response handling: callback / stream / promise #3
Comments
I just tossed a few more details: You can use the @request/api module in combination with any Promise implementation. The first example that I'm showing is using the built in Promise implementation, for cases when you don't want to include I'm currently working on a bunch of modules that are not pushed to GitHub yet, but that's the gist of it. I'm open for suggestions. What I was showing in the first few examples was the most bare bone API that each HTTP client wrapper should implement - just a function that accepts an options object. As you can anything else can be built around that, and there is no need for the API implementation to be part of your module. |
Perfect @simov ! I reviewed all api sections and all looks good to me. It's so flexible. Kudos for your design! I think at this point it is time for me to create an alpha version of |
I just refactored The |
That's great! Just keep in mind that the @request/core refactoring is not published yet, it just takes a bit more time. The only change for you would be that the module containing most of the request features enabled won't be called @request/client but something else probably. Other than that everything else should work as it is. |
Perfect. 👍 Indeed, no rush there, I made the refactoring in a branch. |
IMHO the interface would need polishing in regard to the response handling so that alternative implementations can pop up.
First off, the callback needs to be specified in detail. It can be modelled after Request's callback definition:
However, when I read this I realise that especially the second parameter is highly implementation specific. In order to make implementations replaceable we would need to define a general response object I guess.
Handling responses as a stream or a promise would ideally be loaded as an optional dependency. In particular for the promise I would define:
The text was updated successfully, but these errors were encountered: