-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
Description
There are two things that can be injected in order to perform Http requests, Http or HttpFactory. Http is a class with the primary method of request, plus some shortcut methods like get, post, etc. HttpFactory is a function equivalent to Http.request.
I think having HttpFactory adds more concepts/complexity than is warranted, and I'd like to remove it. For one, it requires two more pages of documentation. One page to document the factory itself, and another to document the IHttp interface that exists solely to provide type information for the factory.
// Factory
import {HttpFactory, IHttp} from 'angular2/http';
class MyComponent {
constructor(@Inject(HttpFactory) http:IHttp) {
http('angular.json').subscribe(ng => this.angular = ng);
}
}
// Class
import {Http} from 'angular2/http';
class MyComponent {
constructor(http:Http) {
http.request('angular.json').subscribe(ng => this.angular = ng);
}
}The idea of having a simple callable function instead of calling a class method is nice, but I think the trade-off of additional concepts isn't worth the overhead.
Reactions are currently unavailable