AFAIR there was an issue and they declined to implement it. They don't want to 
maintain all kinds of features usually requested around HTTP as part of Angular 
and I understand. 
AFAIR I used streaming with the http package. I don't remember where. If I find 
the code I can post it. It wasn't difficult, only a bit difficult to find. 

On Saturday, January 23, 2016 at 4:46:36 AM UTC+1, Douglas Miller wrote:
> I just spent a few hours wrestling with it (the error messages I got weren't 
> very meaningful), and it appears Angular 2's injector can't handle any class 
> not annotated with @Injectable or another Angular-specific annotation. This 
> means Dart's existing non-Angular classes for http handling cannot be 
> injected, and thus cannot have mocks injected in their place. I can write 
> injectable wrappers easily enough, but that's exactly the sort of boilerplate 
> busywork that Angular is supposed to help avoid.
> 
> 
> So, I guess I'll write injectable wrappers for now, but having angular2/http 
> available in Dart would be much preferred. I suppose injection of 
> non-annotated classes that have a suitable constructor might also work, but 
> HttpRequest in dart:html seems to be intended for a single request and 
> BrowserClient in package:http says it can't do streaming. What would be the 
> best way to try to get this handled long term, submit an issue report on 
> github?
> 
> On Friday, January 22, 2016 at 1:52:40 PM UTC-8, Günter Zöchbauer wrote:
> I built this code just to get tests running I ported from TypeScript to Dart
> 
> import 'dart:async' show Future;
> import 'dart:html' show HttpRequest;
> import 'dart:convert' show JSON;
> 
> class Http {
>   Future<Response> get(String uri) async {
>     final HttpRequest req = new HttpRequest()..open('GET', uri);
>     await req.onLoadEnd.first;
>     req.send();
>     return new Response(req);
>   }
> }
> 
> class Response {
>   final HttpRequest request;
>   Response(this.request);
> 
>   String text() => request.responseText;
>   dynamic json() => JSON.decode(request.response);
> 
> } 
> 
> It has only a `get()` method, but other methods are quite similar.
> You can get inspiration from the TypeScript source about what features to add.
> For mocking, just extend it `class MockHttp extends Http {` and override the 
> methods with dummy actions.
> 
> On Friday, January 22, 2016 at 7:42:35 PM UTC+1, Douglas Miller wrote:
> But does that work with Angular's dependency injection? I want to be able to 
> mock it in tests.
> 
> 
> ...some quick googling says probably yes, I think. I'm new to Dart as well as 
> Angular2, looks like I should have explored what Dart itself provides a bit 
> more.
> 
> On Friday, January 22, 2016 at 4:00:53 AM UTC-8, Günter Zöchbauer wrote:
> There is no Dart implementation for Http. You can just use what `dart:html` 
> or `package:http` provide or create your own wrapper class if you want 
> specific functionality. 
> 
> On Friday, January 22, 2016 at 6:08:35 AM UTC+1, Douglas Miller wrote:
> The api docs say there's an angular2/http library in JavaScript and 
> TypeScript, but as far as I can tell it doesn't exist in the Dart version. Am 
> I missing something? Is it not implemented yet? Something else?
> 
> 
> The Dart api docs essentially say "see JavaScript docs" full stop, and I was 
> under the impression that the use of code generation meant all three 
> languages would have all exactly the same Angular features, so I'm a bit 
> surprised and disappointed if this is missing. Searching through the Dart 
> source that pub got for me, angular2/http does not exist and only one class 
> (angular2/src/services/xhr_impl) does anything with http, and that class 
> appears to be intended for internal use only.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to