Breaking Change: dart:html HttpRequest.get/getWithCredentials

235 views
Skip to first unread message

Pete Blois

unread,
Jan 31, 2013, 2:56:10 PM1/31/13
to mi...@dartlang.org
FYI-
We'll be removing the HttpRequest.get and getWithCredentials factory constructors and replacing them with static methods returning futures. These are primarily ease-of-use methods and we're looking to make them a bit easier to use.

Old syntax:
new HttpRequest.get(url, (xhr) {
  if (xhr.status == 200) {
    var result = xhr.response;
  } else {
    // error?
  }
});

New syntax:
HttpRequest.request(url).then(
  (xhr) {
    var result = xhr.response;
  },
  onError: (e) {
     // error!
  });

HttpRequest.getWithCredentials will be HttpRequest.request(url, withCredentials: true);

For simple get scenarios you can use HttpRequest.getString(url) which returns a Future<String>.

Shannon Behrens

unread,
Feb 6, 2013, 10:11:27 PM2/6/13
to General Dart Discussion
Was there supposed to be a deprecation period? I was kind of surprised by this today since yesterday, I had no deprecation warnings, and today my code broke.

Thanks!
-jj


--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 

Pete Blois

unread,
Feb 7, 2013, 12:08:54 PM2/7/13
to mi...@dartlang.org
We've only been deprecating the very heavily used APIs- there will still be non-deprecated breaking changes coming, but hopefully they aren't too difficult to integrate.
Reply all
Reply to author
Forward
0 new messages