-
Notifications
You must be signed in to change notification settings - Fork 716
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
Make the recommendation to not use dart:io
/dart:html
for HTTP requests stronger
#5391
Conversation
dart:io
/dart:html
for HTTP requests strongdart:io
/dart:html
for HTTP requests stronger
// ··· | ||
} | ||
``` | ||
You should avoid directly using `dart:html` to make HTTP requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you think that I should just remove this section completely.
httpClient.close(); | ||
} | ||
``` | ||
You should avoid directly using `dart:io` to make HTTP requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you think that I should just remove this section completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to keep these sections for two releases or so to point users in the right direction. Curious what Marya thinks though.
In the sections you remove, do consider linking to the /tutorials/server/fetch-data
page as an alternative to learn more though since these changes remove learning material.
I do think making the corresponding note/warning on the API's dartdocs more prominent will have a larger effect than any changes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion! I've added a link to the tutorial.
There is a code review out for making the corresponding change to the API docs:
https://dart-review.googlesource.com/c/sdk/+/340283
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to keep these sections for two releases or so to point users in the right direction. Curious what Marya thinks though.
I'm wondering about the severity of this discouragement. Like, if it's a huge problem that people are using HttpRequest
/ HttpClient
, then I'd say completely remove the sections. If it's not so severe, then a better middle ground (for a release or two, like Parker said), would be to keep the old content, but put your new disclaimer at the top of the section before the old content starts. And also pare down all the recommendation-like parts of the old stuff.
I'd say do this for both pages. So here for example, it'd be:
#### HTTP client
You should avoid directly using `dart:io` to make HTTP requests....
(all your new content up to recommending the fetch-data tutorial)
If you still need to use `HttpClient`, here's an example:
(code block)
If you want to go this route, let me know and I can leave another comment on the other section (dart:html
) with a similar mini-rough draft of: starting with your discouragement text + how I'd pare it down severely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to be pretty forceful about our recommendation - we are using the same initial wording in the SDK documentation. But we are preserving the example so users can find it there.
Wouldn't it be better to avoid having examples in our library tour that should not be used except in rare circumstances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining, definitely trust your judgement here!
You can make the final call here, but just to be extra explicit for readers, you could explicitly state that there's still an example in the sdk docs (that's the API docs right?) if you really need it (like Parker said, having an example in one place then making it disappear too well all of a sudden isn't ideal). So, after lines 245 in this file, and 333 at the end of the html-tour file, something like:
Though no longer recommended / not recommended for the majority of use cases,
you can find more information on / an example of `HttpClient`/`HttpRequest`
in the [API documentation](link-to-api-docs).
Approving in the mean time so you can make the final call, but I'll come back and check again if you do change something else and want another look. Thanks for doing this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the purpose the library tour to indoctrinate developers new to Dart? Those developers should start with package:http
(or some equivalent package).
I preserved the link to the class and it still has an example there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and don't trust my judgement; if often sucks ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the purpose the library tour to indoctrinate developers new to Dart?
Definitely so. What Parker and I are referring to is the kind of nebulous, hard to measure, off-chance that "what if someone, somewhere has a link to this specific section that they hold onto for reference that says "example here for whatever", and the off-chance that they'll be greatly perturbed if all of a sudden that "whatever"s not there any more and it's not immediately obvious where to find it.
This definitely isn't a big deal so again, your call :) And your judgement about how important it is that no one remotely even goes poking around the old stuff unless they're absolutely digging for it is based on a lot more context than I have, I'm just citing a general best practice for tech writing. And yes, you do have the link on the API names which I'm ok with!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed answer. I think that I'm OK with it as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some initial comments, but have some questions too. There are a few other mentions of using HttpRequest elsewhere on the library tour page (like in code blocks in the Future section, and the HTTP server section under dart:io). Do those all need to be changed to use package:http
, or is it not interchangeable like that?
Co-authored-by: Marya <[email protected]>
Co-authored-by: Marya <[email protected]>
Co-authored-by: Marya <[email protected]>
Co-authored-by: Marya <[email protected]>
Co-authored-by: Marya <[email protected]>
Co-authored-by: Marya <[email protected]>
Co-authored-by: Marya <[email protected]>
I updated the |
|
We pull code snippets from source files so they can be analyzed and tested. So the two you edited needed to be updated at the source. I did this for you in 22437f2 :) Thanks for working on this :D |
Thanks for fixing it for me! |
Could someone press the merge button for me? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
…uests stronger (dart-lang#5391) Part of dart-lang/sdk#52023 --------- Co-authored-by: Marya <[email protected]> Co-authored-by: Parker Lougheed <[email protected]>
Part of dart-lang/sdk#52023
Contribution guidelines:
dart format
.<?code-excerpt
need to be updated in their source.dart
file as well.