-
Notifications
You must be signed in to change notification settings - Fork 380
Support both the console and browser equally #22
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
Comments
<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3 Marked this as being blocked by dart-lang/sdk#6943. |
This comment was originally written by [email protected] This would be awesome. In my particular case I'm building a client library for a Rest service. My first priority is to build a CLI application using the Client and for that purpose I will need to use the dart:io's HttpRequest. But I want to reuse the Client lib for a Web Interface later on and will then need to use dart:html's HttpRequest. In order to make that work I have to build wrappers for each HttpRequests. |
<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3 It's worth noting that you can use the http package on both the browser and the console today; you just need to explicitly choose to instantiate either an IOClient or a BrowserClient and pass it in to the code in question. |
This comment was originally written by [email protected] Huh. Why didn't I notice that until now? Please excuse a newbie. :) Reading "http package" I was just thinking of some future http functionality - I didn't know it was a package that already existed. Thank you for guiding me. |
Is anything planned to resolve this? This blocks me from using |
This is blocked on dart-lang/sdk#24581. Once full cross-platform imports are fully supported and stable, I'll fix this ASAP. |
Would it be possible to expose the Client, Request, and Response interfaces separately of the browser and the console environment? It would make writing cross-platform REST libraries much much better, because at least they could accept the Client as a parameter, and they won't be tied to a particular platform, while their initialization could be platform-specific. |
As a temporary measure, I've exposed the I'd be happy to scrap the package as soon as |
Don't export private members from another package. You're going to break your users, and set a bad example for the ecosystem at large. |
I wish http would export these members in the same or very similar way. Any comment on whether or when we can expect that? |
It's still blocked on dart-lang/sdk#24581. |
I don't see why that issue is blocking my request. Why couldn't we introduce an interface that both |
Both |
But |
...which is why this is blocked on dart-lang/sdk#24581 (although as of Dart 1.23 all platforms will be able to import |
If |
Yes, but the API would be substantially worse.
Dart's release cycle is fast, so I'm not especially concerned about adoption time. It'll be a lot easier to adopt than an entirely new API. |
I disagree. It would allow a single interface to be used in platform-agnostic REST clients today, not at some point in the future. |
Fixes #22 Adds config specific imports to make `package:http/http.dart` support all platforms, and allow the `Client` factory constructor to return a valid `Client` for the web platform. This should eliminate almost all need for the platform specific imports for consumers, although it does also add the `io_client.dart` public import. Passes presubmit internally, with edits in only 3 files (they use the IoClient constructor directly, and pass in an HttpClient). Externally build_runner now supports config specific imports as well, I am currently working on validating everything works as expected there with this change. ### New Features * The regular `Client` factory constructor is now usable anywhere that `dart:io` or `dart:html` are available, and will give you an `IoClient` or `BrowserClient` respectively. * The `package:http/http.dart` import is now safe to use on the web (or anywhere that either `dart:io` or `dart:html` are available). ### Breaking Changes * In order to use or reference the `IoClient` directly, you will need to import the new `package:http/io_client.dart` import. This is typically only necessary if you are passing a custom `HttpClient` instance to the constructor, in which case you are already giving up support for web.
<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="96" height="96"hspace="10"> Issue by nex3
Originally opened as dart-lang/sdk#20068
The http package should support IOClient and BrowserClient on even footing. "new http.Client()" should dynamically choose between them based on which is supported.
The text was updated successfully, but these errors were encountered: